home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: LaTeX Document
(document/latex).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| LaTeX Document (document/latex)
| magic
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| LaTeX document text
| default
| |
99%
| file
| LaTeX document, ASCII text
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/281 LaTeX (Subdocument)
| default
| |
100%
| detectItEasy
| Format: plain text[LF]
| default (weak)
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 25 20 49 6e 69 74 69 61 | 6c 20 65 6e 76 69 72 6f |% Initia|l enviro|
|00000010| 6e 6d 65 6e 74 0a 0a 25 | 5c 76 66 69 6c 6c 5c 65 |nment..%|\vfill\e|
|00000020| 6a 65 63 74 0a 5c 63 68 | 61 70 74 65 72 7b 53 74 |ject.\ch|apter{St|
|00000030| 61 6e 64 61 72 64 20 70 | 72 6f 63 65 64 75 72 65 |andard p|rocedure|
|00000040| 73 7d 0a 5c 6c 61 62 65 | 6c 7b 69 6e 69 74 69 61 |s}.\labe|l{initia|
|00000050| 6c 65 6e 76 7d 0a 5c 6c | 61 62 65 6c 7b 62 75 69 |lenv}.\l|abel{bui|
|00000060| 6c 74 69 6e 63 68 61 70 | 74 65 72 7d 0a 0a 5c 6d |ltinchap|ter}..\m|
|00000070| 61 69 6e 69 6e 64 65 78 | 7b 69 6e 69 74 69 61 6c |ainindex|{initial|
|00000080| 20 65 6e 76 69 72 6f 6e | 6d 65 6e 74 7d 0a 5c 6d | environ|ment}.\m|
|00000090| 61 69 6e 69 6e 64 65 78 | 7b 74 6f 70 20 6c 65 76 |ainindex|{top lev|
|000000a0| 65 6c 20 65 6e 76 69 72 | 6f 6e 6d 65 6e 74 7d 0a |el envir|onment}.|
|000000b0| 0a 54 68 69 73 20 63 68 | 61 70 74 65 72 20 64 65 |.This ch|apter de|
|000000c0| 73 63 72 69 62 65 73 20 | 53 63 68 65 6d 65 27 73 |scribes |Scheme's|
|000000d0| 20 62 75 69 6c 74 2d 69 | 6e 20 70 72 6f 63 65 64 | built-i|n proced|
|000000e0| 75 72 65 73 2e 20 20 54 | 68 65 20 69 6e 69 74 69 |ures. T|he initi|
|000000f0| 61 6c 20 28 6f 72 0a 60 | 60 74 6f 70 20 6c 65 76 |al (or.`|`top lev|
|00000100| 65 6c 27 27 29 20 53 63 | 68 65 6d 65 20 65 6e 76 |el'') Sc|heme env|
|00000110| 69 72 6f 6e 6d 65 6e 74 | 20 73 74 61 72 74 73 20 |ironment| starts |
|00000120| 6f 75 74 20 77 69 74 68 | 20 61 20 6e 75 6d 62 65 |out with| a numbe|
|00000130| 72 20 6f 66 20 76 61 72 | 69 61 62 6c 65 73 0a 62 |r of var|iables.b|
|00000140| 6f 75 6e 64 20 74 6f 20 | 6c 6f 63 61 74 69 6f 6e |ound to |location|
|00000150| 73 20 63 6f 6e 74 61 69 | 6e 69 6e 67 20 75 73 65 |s contai|ning use|
|00000160| 66 75 6c 20 76 61 6c 75 | 65 73 2c 20 6d 6f 73 74 |ful valu|es, most|
|00000170| 20 6f 66 20 77 68 69 63 | 68 20 61 72 65 20 70 72 | of whic|h are pr|
|00000180| 69 6d 69 74 69 76 65 0a | 70 72 6f 63 65 64 75 72 |imitive.|procedur|
|00000190| 65 73 20 74 68 61 74 20 | 6d 61 6e 69 70 75 6c 61 |es that |manipula|
|000001a0| 74 65 20 64 61 74 61 2e | 20 20 46 6f 72 20 65 78 |te data.| For ex|
|000001b0| 61 6d 70 6c 65 2c 20 74 | 68 65 20 76 61 72 69 61 |ample, t|he varia|
|000001c0| 62 6c 65 20 5c 69 64 65 | 7b 61 62 73 7d 20 69 73 |ble \ide|{abs} is|
|000001d0| 0a 62 6f 75 6e 64 20 74 | 6f 20 28 61 20 6c 6f 63 |.bound t|o (a loc|
|000001e0| 61 74 69 6f 6e 20 69 6e | 69 74 69 61 6c 6c 79 20 |ation in|itially |
|000001f0| 63 6f 6e 74 61 69 6e 69 | 6e 67 29 20 61 20 70 72 |containi|ng) a pr|
|00000200| 6f 63 65 64 75 72 65 20 | 6f 66 20 6f 6e 65 20 61 |ocedure |of one a|
|00000210| 72 67 75 6d 65 6e 74 0a | 74 68 61 74 20 63 6f 6d |rgument.|that com|
|00000220| 70 75 74 65 73 20 74 68 | 65 20 61 62 73 6f 6c 75 |putes th|e absolu|
|00000230| 74 65 20 76 61 6c 75 65 | 20 6f 66 20 61 20 6e 75 |te value| of a nu|
|00000240| 6d 62 65 72 2c 20 61 6e | 64 20 74 68 65 20 76 61 |mber, an|d the va|
|00000250| 72 69 61 62 6c 65 20 5c | 69 64 65 7b 2b 7d 0a 69 |riable \|ide{+}.i|
|00000260| 73 20 62 6f 75 6e 64 20 | 74 6f 20 61 20 70 72 6f |s bound |to a pro|
|00000270| 63 65 64 75 72 65 20 74 | 68 61 74 20 63 6f 6d 70 |cedure t|hat comp|
|00000280| 75 74 65 73 20 73 75 6d | 73 2e 0a 0a 0a 5c 73 65 |utes sum|s....\se|
|00000290| 63 74 69 6f 6e 7b 42 6f | 6f 6c 65 61 6e 73 7d 0a |ction{Bo|oleans}.|
|000002a0| 5c 6c 61 62 65 6c 7b 62 | 6f 6f 6c 65 61 6e 73 65 |\label{b|ooleanse|
|000002b0| 63 74 69 6f 6e 7d 0a 0a | 54 68 65 20 73 74 61 6e |ction}..|The stan|
|000002c0| 64 61 72 64 20 62 6f 6f | 6c 65 61 6e 20 6f 62 6a |dard boo|lean obj|
|000002d0| 65 63 74 73 20 66 6f 72 | 20 74 72 75 65 20 61 6e |ects for| true an|
|000002e0| 64 20 66 61 6c 73 65 20 | 61 72 65 20 77 72 69 74 |d false |are writ|
|000002f0| 74 65 6e 20 61 73 0a 5c | 73 63 68 74 72 75 65 7b |ten as.\|schtrue{|
|00000300| 7d 20 61 6e 64 20 5c 73 | 63 68 66 61 6c 73 65 2e |} and \s|chfalse.|
|00000310| 5c 73 68 61 72 70 69 6e | 64 65 78 7b 74 7d 5c 73 |\sharpin|dex{t}\s|
|00000320| 68 61 72 70 69 6e 64 65 | 78 7b 66 7d 20 20 57 68 |harpinde|x{f} Wh|
|00000330| 61 74 20 72 65 61 6c 6c | 79 0a 6d 61 74 74 65 72 |at reall|y.matter|
|00000340| 73 2c 20 74 68 6f 75 67 | 68 2c 20 61 72 65 20 74 |s, thoug|h, are t|
|00000350| 68 65 20 6f 62 6a 65 63 | 74 73 20 74 68 61 74 20 |he objec|ts that |
|00000360| 74 68 65 20 53 63 68 65 | 6d 65 20 63 6f 6e 64 69 |the Sche|me condi|
|00000370| 74 69 6f 6e 61 6c 20 65 | 78 70 72 65 73 73 69 6f |tional e|xpressio|
|00000380| 6e 73 0a 28 5c 69 64 65 | 7b 69 66 7d 2c 20 5c 69 |ns.(\ide|{if}, \i|
|00000390| 64 65 7b 63 6f 6e 64 7d | 2c 20 5c 69 64 65 7b 61 |de{cond}|, \ide{a|
|000003a0| 6e 64 7d 2c 20 5c 69 64 | 65 7b 6f 72 7d 2c 20 5c |nd}, \id|e{or}, \|
|000003b0| 69 64 65 7b 64 6f 7d 29 | 20 74 72 65 61 74 20 61 |ide{do})| treat a|
|000003c0| 73 0a 74 72 75 65 5c 69 | 6e 64 65 78 7b 74 72 75 |s.true\i|ndex{tru|
|000003d0| 65 7d 20 6f 72 20 66 61 | 6c 73 65 5c 69 6e 64 65 |e} or fa|lse\inde|
|000003e0| 78 7b 66 61 6c 73 65 7d | 2e 20 20 54 68 65 20 70 |x{false}|. The p|
|000003f0| 68 72 61 73 65 20 60 60 | 61 20 74 72 75 65 20 76 |hrase ``|a true v|
|00000400| 61 6c 75 65 27 27 5c 69 | 6e 64 65 78 7b 74 72 75 |alue''\i|ndex{tru|
|00000410| 65 7d 0a 28 6f 72 20 73 | 6f 6d 65 74 69 6d 65 73 |e}.(or s|ometimes|
|00000420| 20 6a 75 73 74 20 60 60 | 74 72 75 65 27 27 29 20 | just ``|true'') |
|00000430| 6d 65 61 6e 73 20 61 6e | 79 20 6f 62 6a 65 63 74 |means an|y object|
|00000440| 20 74 72 65 61 74 65 64 | 20 61 73 20 74 72 75 65 | treated| as true|
|00000450| 20 62 79 20 74 68 65 0a | 63 6f 6e 64 69 74 69 6f | by the.|conditio|
|00000460| 6e 61 6c 20 65 78 70 72 | 65 73 73 69 6f 6e 73 2c |nal expr|essions,|
|00000470| 20 61 6e 64 20 74 68 65 | 20 70 68 72 61 73 65 20 | and the| phrase |
|00000480| 60 60 61 20 66 61 6c 73 | 65 20 76 61 6c 75 65 27 |``a fals|e value'|
|00000490| 27 5c 69 6e 64 65 78 7b | 66 61 6c 73 65 7d 20 28 |'\index{|false} (|
|000004a0| 6f 72 0a 60 60 66 61 6c | 73 65 27 27 29 20 6d 65 |or.``fal|se'') me|
|000004b0| 61 6e 73 20 61 6e 79 20 | 6f 62 6a 65 63 74 20 74 |ans any |object t|
|000004c0| 72 65 61 74 65 64 20 61 | 73 20 66 61 6c 73 65 20 |reated a|s false |
|000004d0| 62 79 20 74 68 65 20 63 | 6f 6e 64 69 74 69 6f 6e |by the c|ondition|
|000004e0| 61 6c 20 65 78 70 72 65 | 73 73 69 6f 6e 73 2e 0a |al expre|ssions..|
|000004f0| 0a 5c 76 65 73 74 20 4f | 66 20 61 6c 6c 20 74 68 |.\vest O|f all th|
|00000500| 65 20 73 74 61 6e 64 61 | 72 64 20 53 63 68 65 6d |e standa|rd Schem|
|00000510| 65 20 76 61 6c 75 65 73 | 2c 20 6f 6e 6c 79 20 5c |e values|, only \|
|00000520| 73 63 68 66 61 6c 73 65 | 7b 7d 0a 25 20 69 73 20 |schfalse|{}.% is |
|00000530| 67 75 61 72 61 6e 74 65 | 65 64 20 74 6f 20 63 6f |guarante|ed to co|
|00000540| 75 6e 74 0a 63 6f 75 6e | 74 73 20 61 73 20 66 61 |unt.coun|ts as fa|
|00000550| 6c 73 65 20 69 6e 20 63 | 6f 6e 64 69 74 69 6f 6e |lse in c|ondition|
|00000560| 61 6c 20 65 78 70 72 65 | 73 73 69 6f 6e 73 2e 0a |al expre|ssions..|
|00000570| 25 20 20 49 74 20 69 73 | 20 6e 6f 74 0a 25 20 73 |% It is| not.% s|
|00000580| 70 65 63 69 66 69 65 64 | 20 77 68 65 74 68 65 72 |pecified| whether|
|00000590| 20 74 68 65 20 65 6d 70 | 74 79 20 6c 69 73 74 5c | the emp|ty list\|
|000005a0| 69 6e 64 65 78 7b 65 6d | 70 74 79 20 6c 69 73 74 |index{em|pty list|
|000005b0| 7d 20 63 6f 75 6e 74 73 | 20 61 73 20 66 61 6c 73 |} counts| as fals|
|000005c0| 65 0a 25 20 6f 72 20 61 | 73 20 74 72 75 65 20 69 |e.% or a|s true i|
|000005d0| 6e 20 63 6f 6e 64 69 74 | 69 6f 6e 61 6c 20 65 78 |n condit|ional ex|
|000005e0| 70 72 65 73 73 69 6f 6e | 73 2e 0a 45 78 63 65 70 |pression|s..Excep|
|000005f0| 74 20 66 6f 72 20 5c 73 | 63 68 66 61 6c 73 65 7b |t for \s|chfalse{|
|00000600| 7d 2c 0a 25 20 61 6e 64 | 20 70 6f 73 73 69 62 6c |},.% and| possibl|
|00000610| 79 20 74 68 65 20 65 6d | 70 74 79 20 6c 69 73 74 |y the em|pty list|
|00000620| 2c 0a 61 6c 6c 20 73 74 | 61 6e 64 61 72 64 20 53 |,.all st|andard S|
|00000630| 63 68 65 6d 65 20 76 61 | 6c 75 65 73 2c 20 69 6e |cheme va|lues, in|
|00000640| 63 6c 75 64 69 6e 67 20 | 5c 73 63 68 74 72 75 65 |cluding |\schtrue|
|00000650| 2c 0a 70 61 69 72 73 2c | 20 74 68 65 20 65 6d 70 |,.pairs,| the emp|
|00000660| 74 79 20 6c 69 73 74 2c | 20 73 79 6d 62 6f 6c 73 |ty list,| symbols|
|00000670| 2c 20 6e 75 6d 62 65 72 | 73 2c 20 73 74 72 69 6e |, number|s, strin|
|00000680| 67 73 2c 20 76 65 63 74 | 6f 72 73 2c 20 61 6e 64 |gs, vect|ors, and|
|00000690| 20 70 72 6f 63 65 64 75 | 72 65 73 2c 0a 63 6f 75 | procedu|res,.cou|
|000006a0| 6e 74 20 61 73 20 74 72 | 75 65 2e 0a 0a 5c 62 65 |nt as tr|ue...\be|
|000006b0| 67 69 6e 7b 6e 6f 74 65 | 7d 0a 49 6e 20 73 6f 6d |gin{note|}.In som|
|000006c0| 65 20 69 6d 70 6c 65 6d | 65 6e 74 61 74 69 6f 6e |e implem|entation|
|000006d0| 73 20 74 68 65 20 65 6d | 70 74 79 20 6c 69 73 74 |s the em|pty list|
|000006e0| 20 63 6f 75 6e 74 73 20 | 61 73 20 66 61 6c 73 65 | counts |as false|
|000006f0| 2c 20 63 6f 6e 74 72 61 | 72 79 0a 74 6f 20 74 68 |, contra|ry.to th|
|00000700| 65 20 61 62 6f 76 65 2e | 0a 4e 6f 6e 65 74 68 65 |e above.|.Nonethe|
|00000710| 6c 65 73 73 20 61 20 66 | 65 77 20 65 78 61 6d 70 |less a f|ew examp|
|00000720| 6c 65 73 20 69 6e 20 74 | 68 69 73 20 72 65 70 6f |les in t|his repo|
|00000730| 72 74 20 61 73 73 75 6d | 65 20 74 68 61 74 20 74 |rt assum|e that t|
|00000740| 68 65 0a 65 6d 70 74 79 | 20 6c 69 73 74 20 63 6f |he.empty| list co|
|00000750| 75 6e 74 73 20 61 73 20 | 74 72 75 65 2c 20 61 73 |unts as |true, as|
|00000760| 20 69 6e 20 5c 63 69 74 | 65 7b 49 45 45 45 53 63 | in \cit|e{IEEESc|
|00000770| 68 65 6d 65 7d 2e 0a 5c | 65 6e 64 7b 6e 6f 74 65 |heme}..\|end{note|
|00000780| 7d 0a 0a 25 20 5c 62 65 | 67 69 6e 7b 72 61 74 69 |}..% \be|gin{rati|
|00000790| 6f 6e 61 6c 65 7d 0a 25 | 20 46 6f 72 20 68 69 73 |onale}.%| For his|
|000007a0| 74 6f 72 69 63 61 6c 20 | 72 65 61 73 6f 6e 73 20 |torical |reasons |
|000007b0| 73 6f 6d 65 20 69 6d 70 | 6c 65 6d 65 6e 74 61 74 |some imp|lementat|
|000007c0| 69 6f 6e 73 20 72 65 67 | 61 72 64 20 5c 73 63 68 |ions reg|ard \sch|
|000007d0| 66 61 6c 73 65 7b 7d 20 | 61 6e 64 20 74 68 65 0a |false{} |and the.|
|000007e0| 25 20 65 6d 70 74 79 20 | 6c 69 73 74 20 61 73 20 |% empty |list as |
|000007f0| 74 68 65 20 73 61 6d 65 | 20 6f 62 6a 65 63 74 2e |the same| object.|
|00000800| 20 20 54 68 65 73 65 20 | 69 6d 70 6c 65 6d 65 6e | These |implemen|
|00000810| 74 61 74 69 6f 6e 73 20 | 74 68 65 72 65 66 6f 72 |tations |therefor|
|00000820| 65 20 63 61 6e 6e 6f 74 | 0a 25 20 6d 61 6b 65 20 |e cannot|.% make |
|00000830| 74 68 65 20 65 6d 70 74 | 79 20 6c 69 73 74 20 63 |the empt|y list c|
|00000840| 6f 75 6e 74 20 61 73 20 | 74 72 75 65 20 69 6e 20 |ount as |true in |
|00000850| 63 6f 6e 64 69 74 69 6f | 6e 61 6c 20 65 78 70 72 |conditio|nal expr|
|00000860| 65 73 73 69 6f 6e 73 2e | 0a 25 20 5c 65 6e 64 7b |essions.|.% \end{|
|00000870| 72 61 74 69 6f 6e 61 6c | 65 7d 0a 0a 5c 62 65 67 |rational|e}..\beg|
|00000880| 69 6e 7b 6e 6f 74 65 7d | 0a 50 72 6f 67 72 61 6d |in{note}|.Program|
|00000890| 6d 65 72 73 20 61 63 63 | 75 73 74 6f 6d 65 64 20 |mers acc|ustomed |
|000008a0| 74 6f 20 6f 74 68 65 72 | 20 64 69 61 6c 65 63 74 |to other| dialect|
|000008b0| 73 20 6f 66 20 4c 69 73 | 70 20 73 68 6f 75 6c 64 |s of Lis|p should|
|000008c0| 20 62 65 20 61 77 61 72 | 65 20 74 68 61 74 0a 53 | be awar|e that.S|
|000008d0| 63 68 65 6d 65 20 64 69 | 73 74 69 6e 67 75 69 73 |cheme di|stinguis|
|000008e0| 68 65 73 20 62 6f 74 68 | 20 5c 73 63 68 66 61 6c |hes both| \schfal|
|000008f0| 73 65 7b 7d 20 61 6e 64 | 20 74 68 65 20 65 6d 70 |se{} and| the emp|
|00000900| 74 79 20 6c 69 73 74 20 | 66 72 6f 6d 20 74 68 65 |ty list |from the|
|00000910| 20 73 79 6d 62 6f 6c 0a | 5c 69 64 65 7b 6e 69 6c | symbol.|\ide{nil|
|00000920| 7d 2e 0a 5c 65 6e 64 7b | 6e 6f 74 65 7d 0a 0a 5c |}..\end{|note}..\|
|00000930| 76 65 73 74 20 42 6f 6f | 6c 65 61 6e 20 63 6f 6e |vest Boo|lean con|
|00000940| 73 74 61 6e 74 73 20 65 | 76 61 6c 75 61 74 65 20 |stants e|valuate |
|00000950| 74 6f 20 74 68 65 6d 73 | 65 6c 76 65 73 2c 20 73 |to thems|elves, s|
|00000960| 6f 20 74 68 65 79 20 64 | 6f 6e 27 74 20 6e 65 65 |o they d|on't nee|
|00000970| 64 20 74 6f 20 62 65 20 | 71 75 6f 74 65 64 0a 69 |d to be |quoted.i|
|00000980| 6e 20 70 72 6f 67 72 61 | 6d 73 2e 0a 0a 5c 62 65 |n progra|ms...\be|
|00000990| 67 69 6e 7b 73 63 68 65 | 6d 65 7d 0a 5c 73 63 68 |gin{sche|me}.\sch|
|000009a0| 74 72 75 65 20 20 20 20 | 20 20 20 20 20 5c 65 76 |true | \ev|
|000009b0| 20 20 5c 73 63 68 74 72 | 75 65 0a 5c 73 63 68 66 | \schtr|ue.\schf|
|000009c0| 61 6c 73 65 20 20 20 20 | 20 20 20 20 5c 65 76 20 |alse | \ev |
|000009d0| 20 5c 73 63 68 66 61 6c | 73 65 0a 27 5c 73 63 68 | \schfal|se.'\sch|
|000009e0| 66 61 6c 73 65 20 20 20 | 20 20 20 20 5c 65 76 20 |false | \ev |
|000009f0| 20 5c 73 63 68 66 61 6c | 73 65 25 0a 5c 65 6e 64 | \schfal|se%.\end|
|00000a00| 7b 73 63 68 65 6d 65 7d | 0a 0a 0a 5c 62 65 67 69 |{scheme}|...\begi|
|00000a10| 6e 7b 65 6e 74 72 79 7d | 7b 25 0a 5c 70 72 6f 74 |n{entry}|{%.\prot|
|00000a20| 6f 7b 6e 6f 74 7d 7b 20 | 6f 62 6a 7d 7b 65 73 73 |o{not}{ |obj}{ess|
|00000a30| 65 6e 74 69 61 6c 20 70 | 72 6f 63 65 64 75 72 65 |ential p|rocedure|
|00000a40| 7d 7d 0a 0a 5c 69 64 65 | 7b 4e 6f 74 7d 20 72 65 |}}..\ide|{Not} re|
|00000a50| 74 75 72 6e 73 20 5c 73 | 63 68 74 72 75 65 7b 7d |turns \s|chtrue{}|
|00000a60| 20 69 66 20 5c 76 61 72 | 7b 6f 62 6a 7d 20 69 73 | if \var|{obj} is|
|00000a70| 20 66 61 6c 73 65 2c 20 | 61 6e 64 20 72 65 74 75 | false, |and retu|
|00000a80| 72 6e 73 0a 5c 73 63 68 | 66 61 6c 73 65 7b 7d 20 |rns.\sch|false{} |
|00000a90| 6f 74 68 65 72 77 69 73 | 65 2e 0a 0a 5c 62 65 67 |otherwis|e...\beg|
|00000aa0| 69 6e 7b 73 63 68 65 6d | 65 7d 0a 28 6e 6f 74 20 |in{schem|e}.(not |
|00000ab0| 5c 73 63 68 74 72 75 65 | 29 20 20 20 5c 65 76 20 |\schtrue|) \ev |
|00000ac0| 20 5c 73 63 68 66 61 6c | 73 65 0a 28 6e 6f 74 20 | \schfal|se.(not |
|00000ad0| 33 29 20 20 20 20 20 20 | 20 20 20 20 5c 65 76 20 |3) | \ev |
|00000ae0| 20 5c 73 63 68 66 61 6c | 73 65 0a 28 6e 6f 74 20 | \schfal|se.(not |
|00000af0| 28 6c 69 73 74 20 33 29 | 29 20 20 20 5c 65 76 20 |(list 3)|) \ev |
|00000b00| 20 5c 73 63 68 66 61 6c | 73 65 0a 28 6e 6f 74 20 | \schfal|se.(not |
|00000b10| 5c 73 63 68 66 61 6c 73 | 65 29 20 20 5c 65 76 20 |\schfals|e) \ev |
|00000b20| 20 5c 73 63 68 74 72 75 | 65 0a 28 6e 6f 74 20 27 | \schtru|e.(not '|
|00000b30| 28 29 29 20 20 20 20 20 | 20 20 20 5c 65 76 20 20 |()) | \ev |
|00000b40| 5c 73 63 68 66 61 6c 73 | 65 0a 28 6e 6f 74 20 28 |\schfals|e.(not (|
|00000b50| 6c 69 73 74 29 29 20 20 | 20 20 20 5c 65 76 20 20 |list)) | \ev |
|00000b60| 5c 73 63 68 66 61 6c 73 | 65 0a 28 6e 6f 74 20 27 |\schfals|e.(not '|
|00000b70| 6e 69 6c 29 20 20 20 20 | 20 20 20 5c 65 76 20 20 |nil) | \ev |
|00000b80| 5c 73 63 68 66 61 6c 73 | 65 25 0a 5c 65 6e 64 7b |\schfals|e%.\end{|
|00000b90| 73 63 68 65 6d 65 7d 0a | 0a 5c 65 6e 64 7b 65 6e |scheme}.|.\end{en|
|00000ba0| 74 72 79 7d 0a 0a 0a 5c | 62 65 67 69 6e 7b 65 6e |try}...\|begin{en|
|00000bb0| 74 72 79 7d 7b 25 0a 5c | 70 72 6f 74 6f 7b 62 6f |try}{%.\|proto{bo|
|00000bc0| 6f 6c 65 61 6e 3f 7d 7b | 20 6f 62 6a 7d 7b 65 73 |olean?}{| obj}{es|
|00000bd0| 73 65 6e 74 69 61 6c 20 | 70 72 6f 63 65 64 75 72 |sential |procedur|
|00000be0| 65 7d 7d 0a 0a 5c 69 64 | 65 7b 42 6f 6f 6c 65 61 |e}}..\id|e{Boolea|
|00000bf0| 6e 3f 7d 20 72 65 74 75 | 72 6e 73 20 5c 73 63 68 |n?} retu|rns \sch|
|00000c00| 74 72 75 65 7b 7d 20 69 | 66 20 5c 76 61 72 7b 6f |true{} i|f \var{o|
|00000c10| 62 6a 7d 20 69 73 20 65 | 69 74 68 65 72 20 5c 73 |bj} is e|ither \s|
|00000c20| 63 68 74 72 75 65 7b 7d | 20 6f 72 0a 5c 73 63 68 |chtrue{}| or.\sch|
|00000c30| 66 61 6c 73 65 7b 7d 20 | 61 6e 64 20 72 65 74 75 |false{} |and retu|
|00000c40| 72 6e 73 20 5c 73 63 68 | 66 61 6c 73 65 7b 7d 20 |rns \sch|false{} |
|00000c50| 6f 74 68 65 72 77 69 73 | 65 2e 0a 0a 5c 62 65 67 |otherwis|e...\beg|
|00000c60| 69 6e 7b 73 63 68 65 6d | 65 7d 0a 28 62 6f 6f 6c |in{schem|e}.(bool|
|00000c70| 65 61 6e 3f 20 5c 73 63 | 68 66 61 6c 73 65 29 20 |ean? \sc|hfalse) |
|00000c80| 20 5c 65 76 20 20 5c 73 | 63 68 74 72 75 65 0a 28 | \ev \s|chtrue.(|
|00000c90| 62 6f 6f 6c 65 61 6e 3f | 20 30 29 20 20 20 20 20 |boolean?| 0) |
|00000ca0| 20 20 20 20 20 5c 65 76 | 20 20 5c 73 63 68 66 61 | \ev| \schfa|
|00000cb0| 6c 73 65 0a 28 62 6f 6f | 6c 65 61 6e 3f 20 27 28 |lse.(boo|lean? '(|
|00000cc0| 29 29 20 20 20 20 20 20 | 20 20 5c 65 76 20 20 5c |)) | \ev \|
|00000cd0| 73 63 68 66 61 6c 73 65 | 25 0a 5c 65 6e 64 7b 73 |schfalse|%.\end{s|
|00000ce0| 63 68 65 6d 65 7d 0a 0a | 5c 65 6e 64 7b 65 6e 74 |cheme}..|\end{ent|
|00000cf0| 72 79 7d 0a 0a 20 0a 5c | 73 65 63 74 69 6f 6e 7b |ry}.. .\|section{|
|00000d00| 45 71 75 69 76 61 6c 65 | 6e 63 65 20 70 72 65 64 |Equivale|nce pred|
|00000d10| 69 63 61 74 65 73 7d 0a | 5c 6c 61 62 65 6c 7b 65 |icates}.|\label{e|
|00000d20| 71 75 69 76 61 6c 65 6e | 63 65 73 65 63 74 69 6f |quivalen|cesectio|
|00000d30| 6e 7d 0a 0a 41 20 5c 64 | 65 66 69 6e 69 6e 67 7b |n}..A \d|efining{|
|00000d40| 70 72 65 64 69 63 61 74 | 65 7d 20 69 73 20 61 20 |predicat|e} is a |
|00000d50| 70 72 6f 63 65 64 75 72 | 65 20 74 68 61 74 20 61 |procedur|e that a|
|00000d60| 6c 77 61 79 73 20 72 65 | 74 75 72 6e 73 20 61 20 |lways re|turns a |
|00000d70| 62 6f 6f 6c 65 61 6e 0a | 76 61 6c 75 65 20 28 5c |boolean.|value (\|
|00000d80| 73 63 68 74 72 75 65 7b | 7d 20 6f 72 20 5c 73 63 |schtrue{|} or \sc|
|00000d90| 68 66 61 6c 73 65 29 2e | 20 20 41 6e 20 5c 64 65 |hfalse).| An \de|
|00000da0| 66 69 6e 69 6e 67 7b 65 | 71 75 69 76 61 6c 65 6e |fining{e|quivalen|
|00000db0| 63 65 20 70 72 65 64 69 | 63 61 74 65 7d 20 69 73 |ce predi|cate} is|
|00000dc0| 0a 74 68 65 20 63 6f 6d | 70 75 74 61 74 69 6f 6e |.the com|putation|
|00000dd0| 61 6c 20 61 6e 61 6c 6f | 67 75 65 20 6f 66 20 61 |al analo|gue of a|
|00000de0| 20 6d 61 74 68 65 6d 61 | 74 69 63 61 6c 20 65 71 | mathema|tical eq|
|00000df0| 75 69 76 61 6c 65 6e 63 | 65 20 72 65 6c 61 74 69 |uivalenc|e relati|
|00000e00| 6f 6e 20 28 69 74 20 69 | 73 0a 73 79 6d 6d 65 74 |on (it i|s.symmet|
|00000e10| 72 69 63 2c 20 72 65 66 | 6c 65 78 69 76 65 2c 20 |ric, ref|lexive, |
|00000e20| 61 6e 64 20 74 72 61 6e | 73 69 74 69 76 65 29 2e |and tran|sitive).|
|00000e30| 20 20 4f 66 20 74 68 65 | 20 65 71 75 69 76 61 6c | Of the| equival|
|00000e40| 65 6e 63 65 20 70 72 65 | 64 69 63 61 74 65 73 0a |ence pre|dicates.|
|00000e50| 64 65 73 63 72 69 62 65 | 64 20 69 6e 20 74 68 69 |describe|d in thi|
|00000e60| 73 20 73 65 63 74 69 6f | 6e 2c 20 5c 69 64 65 7b |s sectio|n, \ide{|
|00000e70| 65 71 3f 7d 5c 20 69 73 | 20 74 68 65 20 66 69 6e |eq?}\ is| the fin|
|00000e80| 65 73 74 20 6f 72 20 6d | 6f 73 74 0a 64 69 73 63 |est or m|ost.disc|
|00000e90| 72 69 6d 69 6e 61 74 69 | 6e 67 2c 20 61 6e 64 20 |riminati|ng, and |
|00000ea0| 5c 69 64 65 7b 65 71 75 | 61 6c 3f 7d 5c 20 69 73 |\ide{equ|al?}\ is|
|00000eb0| 20 74 68 65 20 63 6f 61 | 72 73 65 73 74 2e 20 20 | the coa|rsest. |
|00000ec0| 5c 69 64 65 7b 45 71 76 | 3f 7d 5c 20 69 73 0a 73 |\ide{Eqv|?}\ is.s|
|00000ed0| 6c 69 67 68 74 6c 79 20 | 6c 65 73 73 20 64 69 73 |lightly |less dis|
|00000ee0| 63 72 69 6d 69 6e 61 74 | 69 6e 67 20 74 68 61 6e |criminat|ing than|
|00000ef0| 20 5c 69 64 65 7b 65 71 | 3f 7d 2e 20 20 5c 74 6f | \ide{eq|?}. \to|
|00000f00| 64 6f 7b 50 69 74 6d 61 | 6e 20 64 6f 65 73 6e 27 |do{Pitma|n doesn'|
|00000f10| 74 20 6c 69 6b 65 0a 74 | 68 69 73 20 70 61 72 61 |t like.t|his para|
|00000f20| 67 72 61 70 68 2e 20 20 | 4c 69 66 74 20 74 68 65 |graph. |Lift the|
|00000f30| 20 64 69 73 63 75 73 73 | 69 6f 6e 20 66 72 6f 6d | discuss|ion from|
|00000f40| 20 74 68 65 20 4d 61 63 | 6c 69 73 70 20 6d 61 6e | the Mac|lisp man|
|00000f50| 75 61 6c 2e 20 20 45 78 | 70 6c 61 69 6e 0a 77 68 |ual. Ex|plain.wh|
|00000f60| 79 20 74 68 65 72 65 27 | 73 20 6d 6f 72 65 20 74 |y there'|s more t|
|00000f70| 68 61 6e 20 6f 6e 65 20 | 70 72 65 64 69 63 61 74 |han one |predicat|
|00000f80| 65 2e 7d 0a 0a 0a 5c 62 | 65 67 69 6e 7b 65 6e 74 |e.}...\b|egin{ent|
|00000f90| 72 79 7d 7b 25 0a 5c 70 | 72 6f 74 6f 7b 65 71 76 |ry}{%.\p|roto{eqv|
|00000fa0| 3f 7d 7b 20 5c 76 61 72 | 69 7b 6f 62 6a 7d 20 5c |?}{ \var|i{obj} \|
|00000fb0| 76 61 72 69 69 7b 6f 62 | 6a 7d 7d 7b 65 73 73 65 |varii{ob|j}}{esse|
|00000fc0| 6e 74 69 61 6c 20 70 72 | 6f 63 65 64 75 72 65 7d |ntial pr|ocedure}|
|00000fd0| 7d 0a 0a 54 68 65 20 5c | 69 64 65 7b 65 71 76 3f |}..The \|ide{eqv?|
|00000fe0| 7d 20 70 72 6f 63 65 64 | 75 72 65 20 64 65 66 69 |} proced|ure defi|
|00000ff0| 6e 65 73 20 61 20 75 73 | 65 66 75 6c 20 65 71 75 |nes a us|eful equ|
|00001000| 69 76 61 6c 65 6e 63 65 | 20 72 65 6c 61 74 69 6f |ivalence| relatio|
|00001010| 6e 20 6f 6e 20 6f 62 6a | 65 63 74 73 2e 0a 42 72 |n on obj|ects..Br|
|00001020| 69 65 66 6c 79 2c 20 69 | 74 20 72 65 74 75 72 6e |iefly, i|t return|
|00001030| 73 20 5c 73 63 68 74 72 | 75 65 7b 7d 20 69 66 20 |s \schtr|ue{} if |
|00001040| 5c 76 61 72 69 7b 6f 62 | 6a 7d 20 61 6e 64 20 5c |\vari{ob|j} and \|
|00001050| 76 61 72 69 69 7b 6f 62 | 6a 7d 20 73 68 6f 75 6c |varii{ob|j} shoul|
|00001060| 64 0a 6e 6f 72 6d 61 6c | 6c 79 20 62 65 20 72 65 |d.normal|ly be re|
|00001070| 67 61 72 64 65 64 20 61 | 73 20 74 68 65 20 73 61 |garded a|s the sa|
|00001080| 6d 65 20 6f 62 6a 65 63 | 74 2e 20 20 54 68 69 73 |me objec|t. This|
|00001090| 20 72 65 6c 61 74 69 6f | 6e 20 69 73 20 6c 65 66 | relatio|n is lef|
|000010a0| 74 20 73 6c 69 67 68 74 | 6c 79 0a 6f 70 65 6e 20 |t slight|ly.open |
|000010b0| 74 6f 20 69 6e 74 65 72 | 70 72 65 74 61 74 69 6f |to inter|pretatio|
|000010c0| 6e 2c 20 62 75 74 20 74 | 68 65 20 66 6f 6c 6c 6f |n, but t|he follo|
|000010d0| 77 69 6e 67 20 70 61 72 | 74 69 61 6c 20 73 70 65 |wing par|tial spe|
|000010e0| 63 69 66 69 63 61 74 69 | 6f 6e 20 6f 66 0a 5c 69 |cificati|on of.\i|
|000010f0| 64 65 7b 65 71 76 3f 7d | 20 68 6f 6c 64 73 20 66 |de{eqv?}| holds f|
|00001100| 6f 72 20 61 6c 6c 20 69 | 6d 70 6c 65 6d 65 6e 74 |or all i|mplement|
|00001110| 61 74 69 6f 6e 73 20 6f | 66 20 53 63 68 65 6d 65 |ations o|f Scheme|
|00001120| 2e 0a 0a 54 68 65 20 5c | 69 64 65 7b 65 71 76 3f |...The \|ide{eqv?|
|00001130| 7d 20 70 72 6f 63 65 64 | 75 72 65 20 72 65 74 75 |} proced|ure retu|
|00001140| 72 6e 73 20 5c 73 63 68 | 74 72 75 65 7b 7d 20 69 |rns \sch|true{} i|
|00001150| 66 3a 0a 0a 5c 62 65 67 | 69 6e 7b 69 74 65 6d 69 |f:..\beg|in{itemi|
|00001160| 7a 65 7d 0a 5c 69 74 65 | 6d 20 5c 76 61 72 69 7b |ze}.\ite|m \vari{|
|00001170| 6f 62 6a 7d 20 61 6e 64 | 20 5c 76 61 72 69 69 7b |obj} and| \varii{|
|00001180| 6f 62 6a 7d 20 61 72 65 | 20 62 6f 74 68 20 5c 73 |obj} are| both \s|
|00001190| 63 68 74 72 75 65 7b 7d | 20 6f 72 20 62 6f 74 68 |chtrue{}| or both|
|000011a0| 20 5c 73 63 68 66 61 6c | 73 65 2e 0a 0a 5c 69 74 | \schfal|se...\it|
|000011b0| 65 6d 20 5c 76 61 72 69 | 7b 6f 62 6a 7d 20 61 6e |em \vari|{obj} an|
|000011c0| 64 20 5c 76 61 72 69 69 | 7b 6f 62 6a 7d 20 61 72 |d \varii|{obj} ar|
|000011d0| 65 20 62 6f 74 68 20 73 | 79 6d 62 6f 6c 73 20 61 |e both s|ymbols a|
|000011e0| 6e 64 0a 0a 5c 62 65 67 | 69 6e 7b 73 63 68 65 6d |nd..\beg|in{schem|
|000011f0| 65 7d 0a 28 73 74 72 69 | 6e 67 3d 3f 20 28 73 79 |e}.(stri|ng=? (sy|
|00001200| 6d 62 6f 6c 2d 3e 73 74 | 72 69 6e 67 20 6f 62 6a |mbol->st|ring obj|
|00001210| 31 29 0a 20 20 20 20 20 | 20 20 20 20 20 28 73 79 |1). | (sy|
|00001220| 6d 62 6f 6c 2d 3e 73 74 | 72 69 6e 67 20 6f 62 6a |mbol->st|ring obj|
|00001230| 32 29 29 0a 20 20 20 20 | 5c 65 76 20 20 5c 73 63 |2)). |\ev \sc|
|00001240| 68 74 72 75 65 25 0a 5c | 65 6e 64 7b 73 63 68 65 |htrue%.\|end{sche|
|00001250| 6d 65 7d 0a 0a 5c 62 65 | 67 69 6e 7b 6e 6f 74 65 |me}..\be|gin{note|
|00001260| 7d 20 0a 54 68 69 73 20 | 61 73 73 75 6d 65 73 20 |} .This |assumes |
|00001270| 74 68 61 74 20 6e 65 69 | 74 68 65 72 20 5c 76 61 |that nei|ther \va|
|00001280| 72 69 7b 6f 62 6a 7d 20 | 6e 6f 72 20 5c 76 61 72 |ri{obj} |nor \var|
|00001290| 69 69 7b 6f 62 6a 7d 20 | 69 73 20 61 6e 20 60 60 |ii{obj} |is an ``|
|000012a0| 75 6e 69 6e 74 65 72 6e | 65 64 0a 73 79 6d 62 6f |unintern|ed.symbo|
|000012b0| 6c 27 27 20 61 73 20 61 | 6c 6c 75 64 65 64 20 74 |l'' as a|lluded t|
|000012c0| 6f 20 69 6e 20 73 65 63 | 74 69 6f 6e 7e 5c 72 65 |o in sec|tion~\re|
|000012d0| 66 7b 73 79 6d 62 6f 6c | 73 65 63 74 69 6f 6e 7d |f{symbol|section}|
|000012e0| 2e 20 20 54 68 69 73 20 | 72 65 70 6f 72 74 20 64 |. This |report d|
|000012f0| 6f 65 73 0a 6e 6f 74 20 | 70 72 65 73 75 6d 65 20 |oes.not |presume |
|00001300| 74 6f 20 73 70 65 63 69 | 66 79 20 74 68 65 20 62 |to speci|fy the b|
|00001310| 65 68 61 76 69 6f 72 20 | 6f 66 20 5c 69 64 65 7b |ehavior |of \ide{|
|00001320| 65 71 76 3f 7d 20 6f 6e | 20 69 6d 70 6c 65 6d 65 |eqv?} on| impleme|
|00001330| 6e 74 61 74 69 6f 6e 2d | 64 65 70 65 6e 64 65 6e |ntation-|dependen|
|00001340| 74 0a 65 78 74 65 6e 73 | 69 6f 6e 73 2e 0a 5c 65 |t.extens|ions..\e|
|00001350| 6e 64 7b 6e 6f 74 65 7d | 0a 0a 5c 69 74 65 6d 20 |nd{note}|..\item |
|00001360| 5c 76 61 72 69 7b 6f 62 | 6a 7d 20 61 6e 64 20 5c |\vari{ob|j} and \|
|00001370| 76 61 72 69 69 7b 6f 62 | 6a 7d 20 61 72 65 20 62 |varii{ob|j} are b|
|00001380| 6f 74 68 20 6e 75 6d 62 | 65 72 73 2c 20 61 72 65 |oth numb|ers, are|
|00001390| 20 6e 75 6d 65 72 69 63 | 61 6c 6c 79 0a 65 71 75 | numeric|ally.equ|
|000013a0| 61 6c 20 28 73 65 65 20 | 5c 69 64 65 7b 3d 7d 2c |al (see |\ide{=},|
|000013b0| 20 73 65 63 74 69 6f 6e | 7e 5c 72 65 66 7b 6e 75 | section|~\ref{nu|
|000013c0| 6d 62 65 72 73 65 63 74 | 69 6f 6e 7d 29 2c 20 61 |mbersect|ion}), a|
|000013d0| 6e 64 20 61 72 65 20 65 | 69 74 68 65 72 20 62 6f |nd are e|ither bo|
|000013e0| 74 68 0a 65 78 61 63 74 | 5c 69 6e 64 65 78 7b 65 |th.exact|\index{e|
|000013f0| 78 61 63 74 7d 20 6f 72 | 20 62 6f 74 68 20 69 6e |xact} or| both in|
|00001400| 65 78 61 63 74 5c 69 6e | 64 65 78 7b 69 6e 65 78 |exact\in|dex{inex|
|00001410| 61 63 74 7d 2e 0a 0a 5c | 69 74 65 6d 20 5c 76 61 |act}...\|item \va|
|00001420| 72 69 7b 6f 62 6a 7d 20 | 61 6e 64 20 5c 76 61 72 |ri{obj} |and \var|
|00001430| 69 69 7b 6f 62 6a 7d 20 | 61 72 65 20 62 6f 74 68 |ii{obj} |are both|
|00001440| 20 63 68 61 72 61 63 74 | 65 72 73 20 61 6e 64 20 | charact|ers and |
|00001450| 61 72 65 20 74 68 65 20 | 73 61 6d 65 0a 63 68 61 |are the |same.cha|
|00001460| 72 61 63 74 65 72 20 61 | 63 63 6f 72 64 69 6e 67 |racter a|ccording|
|00001470| 20 74 6f 20 74 68 65 20 | 5c 69 64 65 7b 63 68 61 | to the |\ide{cha|
|00001480| 72 3d 3f 7d 20 70 72 6f | 63 65 64 75 72 65 0a 28 |r=?} pro|cedure.(|
|00001490| 73 65 63 74 69 6f 6e 7e | 5c 72 65 66 7b 63 68 61 |section~|\ref{cha|
|000014a0| 72 61 63 74 65 72 73 65 | 63 74 69 6f 6e 7d 29 2e |racterse|ction}).|
|000014b0| 0a 0a 5c 69 74 65 6d 20 | 62 6f 74 68 20 5c 76 61 |..\item |both \va|
|000014c0| 72 69 7b 6f 62 6a 7d 20 | 61 6e 64 20 5c 76 61 72 |ri{obj} |and \var|
|000014d0| 69 69 7b 6f 62 6a 7d 20 | 61 72 65 20 74 68 65 20 |ii{obj} |are the |
|000014e0| 65 6d 70 74 79 20 6c 69 | 73 74 2e 0a 0a 5c 69 74 |empty li|st...\it|
|000014f0| 65 6d 20 5c 76 61 72 69 | 7b 6f 62 6a 7d 20 61 6e |em \vari|{obj} an|
|00001500| 64 20 5c 76 61 72 69 69 | 7b 6f 62 6a 7d 20 61 72 |d \varii|{obj} ar|
|00001510| 65 20 70 61 69 72 73 2c | 20 76 65 63 74 6f 72 73 |e pairs,| vectors|
|00001520| 2c 20 6f 72 20 73 74 72 | 69 6e 67 73 20 74 68 61 |, or str|ings tha|
|00001530| 74 20 64 65 6e 6f 74 65 | 20 74 68 65 0a 73 61 6d |t denote| the.sam|
|00001540| 65 20 6c 6f 63 61 74 69 | 6f 6e 73 20 69 6e 20 74 |e locati|ons in t|
|00001550| 68 65 20 73 74 6f 72 65 | 20 28 73 65 63 74 69 6f |he store| (sectio|
|00001560| 6e 7e 5c 72 65 66 7b 73 | 74 6f 72 61 67 65 6d 6f |n~\ref{s|toragemo|
|00001570| 64 65 6c 7d 29 2e 0a 0a | 5c 69 74 65 6d 20 5c 76 |del})...|\item \v|
|00001580| 61 72 69 7b 6f 62 6a 7d | 20 61 6e 64 20 5c 76 61 |ari{obj}| and \va|
|00001590| 72 69 69 7b 6f 62 6a 7d | 20 61 72 65 20 70 72 6f |rii{obj}| are pro|
|000015a0| 63 65 64 75 72 65 73 20 | 77 68 6f 73 65 20 6c 6f |cedures |whose lo|
|000015b0| 63 61 74 69 6f 6e 20 74 | 61 67 73 20 61 72 65 0a |cation t|ags are.|
|000015c0| 65 71 75 61 6c 20 28 73 | 65 63 74 69 6f 6e 7e 5c |equal (s|ection~\|
|000015d0| 72 65 66 7b 6c 61 6d 62 | 64 61 7d 29 2e 0a 5c 65 |ref{lamb|da})..\e|
|000015e0| 6e 64 7b 69 74 65 6d 69 | 7a 65 7d 0a 0a 54 68 65 |nd{itemi|ze}..The|
|000015f0| 20 5c 69 64 65 7b 65 71 | 76 3f 7d 20 70 72 6f 63 | \ide{eq|v?} proc|
|00001600| 65 64 75 72 65 20 72 65 | 74 75 72 6e 73 20 5c 73 |edure re|turns \s|
|00001610| 63 68 66 61 6c 73 65 7b | 7d 20 69 66 3a 0a 0a 5c |chfalse{|} if:..\|
|00001620| 62 65 67 69 6e 7b 69 74 | 65 6d 69 7a 65 7d 0a 5c |begin{it|emize}.\|
|00001630| 69 74 65 6d 20 5c 76 61 | 72 69 7b 6f 62 6a 7d 20 |item \va|ri{obj} |
|00001640| 61 6e 64 20 5c 76 61 72 | 69 69 7b 6f 62 6a 7d 20 |and \var|ii{obj} |
|00001650| 61 72 65 20 6f 66 20 64 | 69 66 66 65 72 65 6e 74 |are of d|ifferent|
|00001660| 20 74 79 70 65 73 0a 28 | 73 65 63 74 69 6f 6e 7e | types.(|section~|
|00001670| 5c 72 65 66 7b 64 69 73 | 6a 6f 69 6e 74 6e 65 73 |\ref{dis|jointnes|
|00001680| 73 7d 29 2e 0a 0a 5c 69 | 74 65 6d 20 6f 6e 65 20 |s})...\i|tem one |
|00001690| 6f 66 20 5c 76 61 72 69 | 7b 6f 62 6a 7d 20 61 6e |of \vari|{obj} an|
|000016a0| 64 20 5c 76 61 72 69 69 | 7b 6f 62 6a 7d 20 69 73 |d \varii|{obj} is|
|000016b0| 20 5c 73 63 68 74 72 75 | 65 7b 7d 20 62 75 74 20 | \schtru|e{} but |
|000016c0| 74 68 65 20 6f 74 68 65 | 72 20 69 73 0a 5c 73 63 |the othe|r is.\sc|
|000016d0| 68 66 61 6c 73 65 7b 7d | 2e 0a 0a 5c 69 74 65 6d |hfalse{}|...\item|
|000016e0| 20 5c 76 61 72 69 7b 6f | 62 6a 7d 20 61 6e 64 20 | \vari{o|bj} and |
|000016f0| 5c 76 61 72 69 69 7b 6f | 62 6a 7d 20 61 72 65 20 |\varii{o|bj} are |
|00001700| 73 79 6d 62 6f 6c 73 20 | 62 75 74 0a 0a 5c 62 65 |symbols |but..\be|
|00001710| 67 69 6e 7b 73 63 68 65 | 6d 65 7d 0a 28 73 74 72 |gin{sche|me}.(str|
|00001720| 69 6e 67 3d 3f 20 28 73 | 79 6d 62 6f 6c 2d 3e 73 |ing=? (s|ymbol->s|
|00001730| 74 72 69 6e 67 20 5c 76 | 61 72 69 7b 6f 62 6a 7d |tring \v|ari{obj}|
|00001740| 29 0a 20 20 20 20 20 20 | 20 20 20 20 28 73 79 6d |). | (sym|
|00001750| 62 6f 6c 2d 3e 73 74 72 | 69 6e 67 20 5c 76 61 72 |bol->str|ing \var|
|00001760| 69 69 7b 6f 62 6a 7d 29 | 29 0a 20 20 20 20 5c 65 |ii{obj})|). \e|
|00001770| 76 20 20 5c 73 63 68 66 | 61 6c 73 65 25 0a 5c 65 |v \schf|alse%.\e|
|00001780| 6e 64 7b 73 63 68 65 6d | 65 7d 0a 0a 5c 69 74 65 |nd{schem|e}..\ite|
|00001790| 6d 20 6f 6e 65 20 6f 66 | 20 5c 76 61 72 69 7b 6f |m one of| \vari{o|
|000017a0| 62 6a 7d 20 61 6e 64 20 | 5c 76 61 72 69 69 7b 6f |bj} and |\varii{o|
|000017b0| 62 6a 7d 20 69 73 20 61 | 6e 20 65 78 61 63 74 20 |bj} is a|n exact |
|000017c0| 6e 75 6d 62 65 72 20 62 | 75 74 20 74 68 65 20 6f |number b|ut the o|
|000017d0| 74 68 65 72 0a 69 73 20 | 61 6e 20 69 6e 65 78 61 |ther.is |an inexa|
|000017e0| 63 74 20 6e 75 6d 62 65 | 72 2e 0a 0a 5c 69 74 65 |ct numbe|r...\ite|
|000017f0| 6d 20 5c 76 61 72 69 7b | 6f 62 6a 7d 20 61 6e 64 |m \vari{|obj} and|
|00001800| 20 5c 76 61 72 69 69 7b | 6f 62 6a 7d 20 61 72 65 | \varii{|obj} are|
|00001810| 20 6e 75 6d 62 65 72 73 | 20 66 6f 72 20 77 68 69 | numbers| for whi|
|00001820| 63 68 20 74 68 65 20 5c | 69 64 65 7b 3d 7d 0a 70 |ch the \|ide{=}.p|
|00001830| 72 6f 63 65 64 75 72 65 | 20 72 65 74 75 72 6e 73 |rocedure| returns|
|00001840| 20 5c 73 63 68 66 61 6c | 73 65 7b 7d 2e 0a 0a 5c | \schfal|se{}...\|
|00001850| 69 74 65 6d 20 5c 76 61 | 72 69 7b 6f 62 6a 7d 20 |item \va|ri{obj} |
|00001860| 61 6e 64 20 5c 76 61 72 | 69 69 7b 6f 62 6a 7d 20 |and \var|ii{obj} |
|00001870| 61 72 65 20 63 68 61 72 | 61 63 74 65 72 73 20 66 |are char|acters f|
|00001880| 6f 72 20 77 68 69 63 68 | 20 74 68 65 20 5c 69 64 |or which| the \id|
|00001890| 65 7b 63 68 61 72 3d 3f | 7d 0a 70 72 6f 63 65 64 |e{char=?|}.proced|
|000018a0| 75 72 65 20 72 65 74 75 | 72 6e 73 20 5c 73 63 68 |ure retu|rns \sch|
|000018b0| 66 61 6c 73 65 7b 7d 2e | 0a 0a 5c 69 74 65 6d 20 |false{}.|..\item |
|000018c0| 6f 6e 65 20 6f 66 20 5c | 76 61 72 69 7b 6f 62 6a |one of \|vari{obj|
|000018d0| 7d 20 61 6e 64 20 5c 76 | 61 72 69 69 7b 6f 62 6a |} and \v|arii{obj|
|000018e0| 7d 20 69 73 20 74 68 65 | 20 65 6d 70 74 79 20 6c |} is the| empty l|
|000018f0| 69 73 74 20 62 75 74 20 | 74 68 65 20 6f 74 68 65 |ist but |the othe|
|00001900| 72 0a 69 73 20 6e 6f 74 | 2e 0a 0a 5c 69 74 65 6d |r.is not|...\item|
|00001910| 20 5c 76 61 72 69 7b 6f | 62 6a 7d 20 61 6e 64 20 | \vari{o|bj} and |
|00001920| 5c 76 61 72 69 69 7b 6f | 62 6a 7d 20 61 72 65 20 |\varii{o|bj} are |
|00001930| 70 61 69 72 73 2c 20 76 | 65 63 74 6f 72 73 2c 20 |pairs, v|ectors, |
|00001940| 6f 72 20 73 74 72 69 6e | 67 73 20 74 68 61 74 20 |or strin|gs that |
|00001950| 64 65 6e 6f 74 65 0a 64 | 69 73 74 69 6e 63 74 20 |denote.d|istinct |
|00001960| 6c 6f 63 61 74 69 6f 6e | 73 2e 0a 0a 5c 69 74 65 |location|s...\ite|
|00001970| 6d 20 5c 76 61 72 69 7b | 6f 62 6a 7d 20 61 6e 64 |m \vari{|obj} and|
|00001980| 20 5c 76 61 72 69 69 7b | 6f 62 6a 7d 20 61 72 65 | \varii{|obj} are|
|00001990| 20 70 72 6f 63 65 64 75 | 72 65 73 20 74 68 61 74 | procedu|res that|
|000019a0| 20 77 6f 75 6c 64 20 62 | 65 68 61 76 65 20 64 69 | would b|ehave di|
|000019b0| 66 66 65 72 65 6e 74 6c | 79 0a 28 72 65 74 75 72 |fferentl|y.(retur|
|000019c0| 6e 20 61 20 64 69 66 66 | 65 72 65 6e 74 20 76 61 |n a diff|erent va|
|000019d0| 6c 75 65 20 6f 72 20 68 | 61 76 65 20 64 69 66 66 |lue or h|ave diff|
|000019e0| 65 72 65 6e 74 20 73 69 | 64 65 20 65 66 66 65 63 |erent si|de effec|
|000019f0| 74 73 29 20 66 6f 72 20 | 73 6f 6d 65 20 61 72 67 |ts) for |some arg|
|00001a00| 75 6d 65 6e 74 73 2e 0a | 0a 5c 65 6e 64 7b 69 74 |uments..|.\end{it|
|00001a10| 65 6d 69 7a 65 7d 0a 0a | 5c 62 65 67 69 6e 7b 73 |emize}..|\begin{s|
|00001a20| 63 68 65 6d 65 7d 0a 28 | 65 71 76 3f 20 27 61 20 |cheme}.(|eqv? 'a |
|00001a30| 27 61 29 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |'a) | |
|00001a40| 20 20 20 20 20 20 20 20 | 5c 65 76 20 20 5c 73 63 | |\ev \sc|
|00001a50| 68 74 72 75 65 0a 28 65 | 71 76 3f 20 27 61 20 27 |htrue.(e|qv? 'a '|
|00001a60| 62 29 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |b) | |
|00001a70| 20 20 20 20 20 20 20 5c | 65 76 20 20 5c 73 63 68 | \|ev \sch|
|00001a80| 66 61 6c 73 65 0a 28 65 | 71 76 3f 20 32 20 32 29 |false.(e|qv? 2 2)|
|00001a90| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001aa0| 20 20 20 20 20 20 20 5c | 65 76 20 20 5c 73 63 68 | \|ev \sch|
|00001ab0| 74 72 75 65 0a 28 65 71 | 76 3f 20 27 28 29 20 27 |true.(eq|v? '() '|
|00001ac0| 28 29 29 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |()) | |
|00001ad0| 20 20 20 20 20 20 5c 65 | 76 20 20 5c 73 63 68 74 | \e|v \scht|
|00001ae0| 72 75 65 0a 28 65 71 76 | 3f 20 31 30 30 30 30 30 |rue.(eqv|? 100000|
|00001af0| 30 30 30 20 31 30 30 30 | 30 30 30 30 30 29 20 20 |000 1000|00000) |
|00001b00| 20 20 20 20 20 5c 65 76 | 20 20 5c 73 63 68 74 72 | \ev| \schtr|
|00001b10| 75 65 0a 28 65 71 76 3f | 20 28 63 6f 6e 73 20 31 |ue.(eqv?| (cons 1|
|00001b20| 20 32 29 20 28 63 6f 6e | 73 20 31 20 32 29 29 20 | 2) (con|s 1 2)) |
|00001b30| 20 20 20 20 5c 65 76 20 | 20 5c 73 63 68 66 61 6c | \ev | \schfal|
|00001b40| 73 65 0a 28 65 71 76 3f | 20 28 6c 61 6d 62 64 61 |se.(eqv?| (lambda|
|00001b50| 20 28 29 20 31 29 0a 20 | 20 20 20 20 20 28 6c 61 | () 1). | (la|
|00001b60| 6d 62 64 61 20 28 29 20 | 32 29 29 20 20 20 20 20 |mbda () |2)) |
|00001b70| 20 20 20 20 20 20 20 20 | 5c 65 76 20 20 5c 73 63 | |\ev \sc|
|00001b80| 68 66 61 6c 73 65 0a 28 | 65 71 76 3f 20 5c 23 66 |hfalse.(|eqv? \#f|
|00001b90| 20 27 6e 69 6c 29 20 20 | 20 20 20 20 20 20 20 20 | 'nil) | |
|00001ba0| 20 20 20 20 20 20 20 20 | 5c 65 76 20 20 5c 73 63 | |\ev \sc|
|00001bb0| 68 66 61 6c 73 65 0a 28 | 6c 65 74 20 28 28 70 20 |hfalse.(|let ((p |
|00001bc0| 28 6c 61 6d 62 64 61 20 | 28 78 29 20 78 29 29 29 |(lambda |(x) x)))|
|00001bd0| 0a 20 20 28 65 71 76 3f | 20 70 20 70 29 29 09 09 |. (eqv?| p p))..|
|00001be0| 20 20 20 20 20 20 20 20 | 20 5c 65 76 20 20 5c 73 | | \ev \s|
|00001bf0| 63 68 74 72 75 65 25 0a | 5c 65 6e 64 7b 73 63 68 |chtrue%.|\end{sch|
|00001c00| 65 6d 65 7d 0a 0a 54 68 | 65 20 66 6f 6c 6c 6f 77 |eme}..Th|e follow|
|00001c10| 69 6e 67 20 65 78 61 6d | 70 6c 65 73 20 69 6c 6c |ing exam|ples ill|
|00001c20| 75 73 74 72 61 74 65 20 | 63 61 73 65 73 20 69 6e |ustrate |cases in|
|00001c30| 20 77 68 69 63 68 20 74 | 68 65 20 61 62 6f 76 65 | which t|he above|
|00001c40| 20 72 75 6c 65 73 20 64 | 6f 0a 6e 6f 74 20 66 75 | rules d|o.not fu|
|00001c50| 6c 6c 79 20 73 70 65 63 | 69 66 79 20 74 68 65 20 |lly spec|ify the |
|00001c60| 62 65 68 61 76 69 6f 72 | 20 6f 66 20 5c 69 64 65 |behavior| of \ide|
|00001c70| 7b 65 71 76 3f 7d 2e 20 | 20 41 6c 6c 20 74 68 61 |{eqv?}. | All tha|
|00001c80| 74 20 63 61 6e 20 62 65 | 20 73 61 69 64 0a 61 62 |t can be| said.ab|
|00001c90| 6f 75 74 20 73 75 63 68 | 20 63 61 73 65 73 20 69 |out such| cases i|
|00001ca0| 73 20 74 68 61 74 20 74 | 68 65 20 76 61 6c 75 65 |s that t|he value|
|00001cb0| 20 72 65 74 75 72 6e 65 | 64 20 62 79 20 5c 69 64 | returne|d by \id|
|00001cc0| 65 7b 65 71 76 3f 7d 20 | 6d 75 73 74 20 62 65 20 |e{eqv?} |must be |
|00001cd0| 61 0a 62 6f 6f 6c 65 61 | 6e 2e 0a 0a 5c 62 65 67 |a.boolea|n...\beg|
|00001ce0| 69 6e 7b 73 63 68 65 6d | 65 7d 0a 28 65 71 76 3f |in{schem|e}.(eqv?|
|00001cf0| 20 22 22 20 22 22 29 20 | 20 20 20 20 20 20 20 20 | "" "") | |
|00001d00| 20 20 20 20 5c 65 76 20 | 20 5c 75 6e 73 70 65 63 | \ev | \unspec|
|00001d10| 69 66 69 65 64 0a 28 65 | 71 76 3f 20 27 5c 23 28 |ified.(e|qv? '\#(|
|00001d20| 29 20 27 5c 23 28 29 29 | 20 20 20 20 20 20 20 20 |) '\#())| |
|00001d30| 20 5c 65 76 20 20 5c 75 | 6e 73 70 65 63 69 66 69 | \ev \u|nspecifi|
|00001d40| 65 64 0a 28 65 71 76 3f | 20 28 6c 61 6d 62 64 61 |ed.(eqv?| (lambda|
|00001d50| 20 28 78 29 20 78 29 0a | 20 20 20 20 20 20 28 6c | (x) x).| (l|
|00001d60| 61 6d 62 64 61 20 28 78 | 29 20 78 29 29 20 20 20 |ambda (x|) x)) |
|00001d70| 20 5c 65 76 20 20 5c 75 | 6e 73 70 65 63 69 66 69 | \ev \u|nspecifi|
|00001d80| 65 64 0a 28 65 71 76 3f | 20 28 6c 61 6d 62 64 61 |ed.(eqv?| (lambda|
|00001d90| 20 28 78 29 20 78 29 0a | 20 20 20 20 20 20 28 6c | (x) x).| (l|
|00001da0| 61 6d 62 64 61 20 28 79 | 29 20 79 29 29 20 20 20 |ambda (y|) y)) |
|00001db0| 20 5c 65 76 20 20 5c 75 | 6e 73 70 65 63 69 66 69 | \ev \u|nspecifi|
|00001dc0| 65 64 25 0a 5c 65 6e 64 | 7b 73 63 68 65 6d 65 7d |ed%.\end|{scheme}|
|00001dd0| 0a 0a 54 68 65 20 6e 65 | 78 74 20 73 65 74 20 6f |..The ne|xt set o|
|00001de0| 66 20 65 78 61 6d 70 6c | 65 73 20 73 68 6f 77 73 |f exampl|es shows|
|00001df0| 20 74 68 65 20 75 73 65 | 20 6f 66 20 5c 69 64 65 | the use| of \ide|
|00001e00| 7b 65 71 76 3f 7d 5c 20 | 77 69 74 68 20 70 72 6f |{eqv?}\ |with pro|
|00001e10| 63 65 64 75 72 65 73 0a | 74 68 61 74 20 68 61 76 |cedures.|that hav|
|00001e20| 65 20 6c 6f 63 61 6c 20 | 73 74 61 74 65 2e 20 20 |e local |state. |
|00001e30| 5c 69 64 65 7b 47 65 6e | 2d 63 6f 75 6e 74 65 72 |\ide{Gen|-counter|
|00001e40| 7d 20 6d 75 73 74 20 72 | 65 74 75 72 6e 20 61 20 |} must r|eturn a |
|00001e50| 64 69 73 74 69 6e 63 74 | 0a 70 72 6f 63 65 64 75 |distinct|.procedu|
|00001e60| 72 65 20 65 76 65 72 79 | 20 74 69 6d 65 2c 20 73 |re every| time, s|
|00001e70| 69 6e 63 65 20 65 61 63 | 68 20 70 72 6f 63 65 64 |ince eac|h proced|
|00001e80| 75 72 65 20 68 61 73 20 | 69 74 73 20 6f 77 6e 20 |ure has |its own |
|00001e90| 69 6e 74 65 72 6e 61 6c | 20 63 6f 75 6e 74 65 72 |internal| counter|
|00001ea0| 2e 0a 5c 69 64 65 7b 47 | 65 6e 2d 6c 6f 73 65 72 |..\ide{G|en-loser|
|00001eb0| 7d 2c 20 68 6f 77 65 76 | 65 72 2c 20 72 65 74 75 |}, howev|er, retu|
|00001ec0| 72 6e 73 20 65 71 75 69 | 76 61 6c 65 6e 74 20 70 |rns equi|valent p|
|00001ed0| 72 6f 63 65 64 75 72 65 | 73 20 65 61 63 68 20 74 |rocedure|s each t|
|00001ee0| 69 6d 65 2c 20 73 69 6e | 63 65 0a 74 68 65 20 6c |ime, sin|ce.the l|
|00001ef0| 6f 63 61 6c 20 73 74 61 | 74 65 20 64 6f 65 73 20 |ocal sta|te does |
|00001f00| 6e 6f 74 20 61 66 66 65 | 63 74 20 74 68 65 20 76 |not affe|ct the v|
|00001f10| 61 6c 75 65 20 6f 72 20 | 73 69 64 65 20 65 66 66 |alue or |side eff|
|00001f20| 65 63 74 73 20 6f 66 20 | 74 68 65 0a 70 72 6f 63 |ects of |the.proc|
|00001f30| 65 64 75 72 65 73 2e 0a | 0a 5c 62 65 67 69 6e 7b |edures..|.\begin{|
|00001f40| 73 63 68 65 6d 65 7d 0a | 28 64 65 66 69 6e 65 20 |scheme}.|(define |
|00001f50| 67 65 6e 2d 63 6f 75 6e | 74 65 72 0a 20 20 28 6c |gen-coun|ter. (l|
|00001f60| 61 6d 62 64 61 20 28 29 | 0a 20 20 20 20 28 6c 65 |ambda ()|. (le|
|00001f70| 74 20 28 28 6e 20 30 29 | 29 0a 20 20 20 20 20 20 |t ((n 0)|). |
|00001f80| 28 6c 61 6d 62 64 61 20 | 28 29 20 28 73 65 74 21 |(lambda |() (set!|
|00001f90| 20 6e 20 28 2b 20 6e 20 | 31 29 29 20 6e 29 29 29 | n (+ n |1)) n)))|
|00001fa0| 29 0a 28 6c 65 74 20 28 | 28 67 20 28 67 65 6e 2d |).(let (|(g (gen-|
|00001fb0| 63 6f 75 6e 74 65 72 29 | 29 29 0a 20 20 28 65 71 |counter)|)). (eq|
|00001fc0| 76 3f 20 67 20 67 29 29 | 20 20 20 20 20 20 20 20 |v? g g))| |
|00001fd0| 20 20 20 5c 65 76 20 20 | 5c 73 63 68 74 72 75 65 | \ev |\schtrue|
|00001fe0| 0a 28 65 71 76 3f 20 28 | 67 65 6e 2d 63 6f 75 6e |.(eqv? (|gen-coun|
|00001ff0| 74 65 72 29 20 28 67 65 | 6e 2d 63 6f 75 6e 74 65 |ter) (ge|n-counte|
|00002000| 72 29 29 0a 20 20 20 20 | 20 20 20 20 20 20 20 20 |r)). | |
|00002010| 20 20 20 20 20 20 20 20 | 20 20 20 20 5c 65 76 20 | | \ev |
|00002020| 20 5c 73 63 68 66 61 6c | 73 65 0a 28 64 65 66 69 | \schfal|se.(defi|
|00002030| 6e 65 20 67 65 6e 2d 6c | 6f 73 65 72 0a 20 20 28 |ne gen-l|oser. (|
|00002040| 6c 61 6d 62 64 61 20 28 | 29 0a 20 20 20 20 28 6c |lambda (|). (l|
|00002050| 65 74 20 28 28 6e 20 30 | 29 29 0a 20 20 20 20 20 |et ((n 0|)). |
|00002060| 20 28 6c 61 6d 62 64 61 | 20 28 29 20 28 73 65 74 | (lambda| () (set|
|00002070| 21 20 6e 20 28 2b 20 6e | 20 31 29 29 20 32 37 29 |! n (+ n| 1)) 27)|
|00002080| 29 29 29 0a 28 6c 65 74 | 20 28 28 67 20 28 67 65 |))).(let| ((g (ge|
|00002090| 6e 2d 6c 6f 73 65 72 29 | 29 29 0a 20 20 28 65 71 |n-loser)|)). (eq|
|000020a0| 76 3f 20 67 20 67 29 29 | 20 20 20 20 20 20 20 20 |v? g g))| |
|000020b0| 20 20 20 5c 65 76 20 20 | 5c 73 63 68 74 72 75 65 | \ev |\schtrue|
|000020c0| 0a 28 65 71 76 3f 20 28 | 67 65 6e 2d 6c 6f 73 65 |.(eqv? (|gen-lose|
|000020d0| 72 29 20 28 67 65 6e 2d | 6c 6f 73 65 72 29 29 0a |r) (gen-|loser)).|
|000020e0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000020f0| 20 20 20 20 20 20 20 20 | 5c 65 76 20 20 5c 75 6e | |\ev \un|
|00002100| 73 70 65 63 69 66 69 65 | 64 0a 0a 28 6c 65 74 72 |specifie|d..(letr|
|00002110| 65 63 20 28 28 66 20 28 | 6c 61 6d 62 64 61 20 28 |ec ((f (|lambda (|
|00002120| 29 20 28 69 66 20 28 65 | 71 76 3f 20 66 20 67 29 |) (if (e|qv? f g)|
|00002130| 20 27 62 6f 74 68 20 27 | 66 29 29 29 0a 20 20 20 | 'both '|f))). |
|00002140| 20 20 20 20 20 20 28 67 | 20 28 6c 61 6d 62 64 61 | (g| (lambda|
|00002150| 20 28 29 20 28 69 66 20 | 28 65 71 76 3f 20 66 20 | () (if |(eqv? f |
|00002160| 67 29 20 27 62 6f 74 68 | 20 27 67 29 29 29 0a 20 |g) 'both| 'g))). |
|00002170| 20 28 65 71 76 3f 20 66 | 20 67 29 29 0a 20 20 20 | (eqv? f| g)). |
|00002180| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002190| 20 20 20 20 20 5c 65 76 | 20 20 5c 75 6e 73 70 65 | \ev| \unspe|
|000021a0| 63 69 66 69 65 64 0a 0a | 28 6c 65 74 72 65 63 20 |cified..|(letrec |
|000021b0| 28 28 66 20 28 6c 61 6d | 62 64 61 20 28 29 20 28 |((f (lam|bda () (|
|000021c0| 69 66 20 28 65 71 76 3f | 20 66 20 67 29 20 27 66 |if (eqv?| f g) 'f|
|000021d0| 20 27 62 6f 74 68 29 29 | 29 0a 20 20 20 20 20 20 | 'both))|). |
|000021e0| 20 20 20 28 67 20 28 6c | 61 6d 62 64 61 20 28 29 | (g (l|ambda ()|
|000021f0| 20 28 69 66 20 28 65 71 | 76 3f 20 66 20 67 29 20 | (if (eq|v? f g) |
|00002200| 27 67 20 27 62 6f 74 68 | 29 29 29 0a 20 20 28 65 |'g 'both|))). (e|
|00002210| 71 76 3f 20 66 20 67 29 | 29 0a 20 20 20 20 20 20 |qv? f g)|). |
|00002220| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002230| 20 20 5c 65 76 20 20 5c | 73 63 68 66 61 6c 73 65 | \ev \|schfalse|
|00002240| 25 0a 5c 65 6e 64 7b 73 | 63 68 65 6d 65 7d 0a 0a |%.\end{s|cheme}..|
|00002250| 25 20 4f 62 6a 65 63 74 | 73 20 6f 66 20 64 69 73 |% Object|s of dis|
|00002260| 74 69 6e 63 74 20 74 79 | 70 65 73 20 6d 75 73 74 |tinct ty|pes must|
|00002270| 20 6e 65 76 65 72 20 62 | 65 20 72 65 67 61 72 64 | never b|e regard|
|00002280| 65 64 20 61 73 20 74 68 | 65 20 73 61 6d 65 20 6f |ed as th|e same o|
|00002290| 62 6a 65 63 74 2c 0a 25 | 20 65 78 63 65 70 74 20 |bject,.%| except |
|000022a0| 74 68 61 74 20 5c 73 63 | 68 66 61 6c 73 65 7b 7d |that \sc|hfalse{}|
|000022b0| 20 61 6e 64 20 74 68 65 | 20 65 6d 70 74 79 20 6c | and the| empty l|
|000022c0| 69 73 74 5c 69 6e 64 65 | 78 7b 65 6d 70 74 79 20 |ist\inde|x{empty |
|000022d0| 6c 69 73 74 7d 20 61 72 | 65 20 70 65 72 6d 69 74 |list} ar|e permit|
|000022e0| 74 65 64 20 74 6f 0a 25 | 20 62 65 20 69 64 65 6e |ted to.%| be iden|
|000022f0| 74 69 63 61 6c 2e 0a 25 | 0a 25 20 5c 62 65 67 69 |tical..%|.% \begi|
|00002300| 6e 7b 73 63 68 65 6d 65 | 7d 0a 25 20 28 65 71 76 |n{scheme|}.% (eqv|
|00002310| 3f 20 27 28 29 20 5c 73 | 63 68 66 61 6c 73 65 29 |? '() \s|chfalse)|
|00002320| 20 20 20 20 5c 65 76 20 | 20 5c 75 6e 73 70 65 63 | \ev | \unspec|
|00002330| 69 66 69 65 64 25 0a 25 | 20 5c 65 6e 64 7b 73 63 |ified%.%| \end{sc|
|00002340| 68 65 6d 65 7d 0a 0a 53 | 69 6e 63 65 20 69 74 20 |heme}..S|ince it |
|00002350| 69 73 20 61 6e 20 65 72 | 72 6f 72 20 74 6f 20 6d |is an er|ror to m|
|00002360| 6f 64 69 66 79 20 63 6f | 6e 73 74 61 6e 74 20 6f |odify co|nstant o|
|00002370| 62 6a 65 63 74 73 20 28 | 74 68 6f 73 65 20 72 65 |bjects (|those re|
|00002380| 74 75 72 6e 65 64 20 62 | 79 0a 6c 69 74 65 72 61 |turned b|y.litera|
|00002390| 6c 20 65 78 70 72 65 73 | 73 69 6f 6e 73 29 2c 20 |l expres|sions), |
|000023a0| 69 6d 70 6c 65 6d 65 6e | 74 61 74 69 6f 6e 73 20 |implemen|tations |
|000023b0| 61 72 65 20 70 65 72 6d | 69 74 74 65 64 2c 20 74 |are perm|itted, t|
|000023c0| 68 6f 75 67 68 20 6e 6f | 74 0a 72 65 71 75 69 72 |hough no|t.requir|
|000023d0| 65 64 2c 20 74 6f 20 73 | 68 61 72 65 20 73 74 72 |ed, to s|hare str|
|000023e0| 75 63 74 75 72 65 20 62 | 65 74 77 65 65 6e 20 63 |ucture b|etween c|
|000023f0| 6f 6e 73 74 61 6e 74 73 | 20 77 68 65 72 65 20 61 |onstants| where a|
|00002400| 70 70 72 6f 70 72 69 61 | 74 65 2e 20 20 54 68 75 |ppropria|te. Thu|
|00002410| 73 0a 74 68 65 20 76 61 | 6c 75 65 20 6f 66 20 5c |s.the va|lue of \|
|00002420| 69 64 65 7b 65 71 76 3f | 7d 20 6f 6e 20 63 6f 6e |ide{eqv?|} on con|
|00002430| 73 74 61 6e 74 73 20 69 | 73 20 73 6f 6d 65 74 69 |stants i|s someti|
|00002440| 6d 65 73 0a 69 6d 70 6c | 65 6d 65 6e 74 61 74 69 |mes.impl|ementati|
|00002450| 6f 6e 2d 64 65 70 65 6e | 64 65 6e 74 2e 0a 0a 5c |on-depen|dent...\|
|00002460| 62 65 67 69 6e 7b 73 63 | 68 65 6d 65 7d 0a 28 65 |begin{sc|heme}.(e|
|00002470| 71 76 3f 20 27 28 61 29 | 20 27 28 61 29 29 20 20 |qv? '(a)| '(a)) |
|00002480| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 5c | | \|
|00002490| 65 76 20 20 5c 75 6e 73 | 70 65 63 69 66 69 65 64 |ev \uns|pecified|
|000024a0| 0a 28 65 71 76 3f 20 22 | 61 22 20 22 61 22 29 20 |.(eqv? "|a" "a") |
|000024b0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000024c0| 20 20 5c 65 76 20 20 5c | 75 6e 73 70 65 63 69 66 | \ev \|unspecif|
|000024d0| 69 65 64 0a 28 65 71 76 | 3f 20 27 28 62 29 20 28 |ied.(eqv|? '(b) (|
|000024e0| 63 64 72 20 27 28 61 20 | 62 29 29 29 09 20 5c 65 |cdr '(a |b))). \e|
|000024f0| 76 20 20 5c 75 6e 73 70 | 65 63 69 66 69 65 64 0a |v \unsp|ecified.|
|00002500| 28 6c 65 74 20 28 28 78 | 20 27 28 61 29 29 29 0a |(let ((x| '(a))).|
|00002510| 20 20 28 65 71 76 3f 20 | 78 20 78 29 29 20 20 20 | (eqv? |x x)) |
|00002520| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002530| 20 5c 65 76 20 20 5c 73 | 63 68 74 72 75 65 25 0a | \ev \s|chtrue%.|
|00002540| 5c 65 6e 64 7b 73 63 68 | 65 6d 65 7d 0a 0a 5c 62 |\end{sch|eme}..\b|
|00002550| 65 67 69 6e 7b 72 61 74 | 69 6f 6e 61 6c 65 7d 20 |egin{rat|ionale} |
|00002560| 0a 54 68 65 20 61 62 6f | 76 65 20 64 65 66 69 6e |.The abo|ve defin|
|00002570| 69 74 69 6f 6e 20 6f 66 | 20 5c 69 64 65 7b 65 71 |ition of| \ide{eq|
|00002580| 76 3f 7d 20 61 6c 6c 6f | 77 73 20 69 6d 70 6c 65 |v?} allo|ws imple|
|00002590| 6d 65 6e 74 61 74 69 6f | 6e 73 20 6c 61 74 69 74 |mentatio|ns latit|
|000025a0| 75 64 65 20 69 6e 0a 74 | 68 65 69 72 20 74 72 65 |ude in.t|heir tre|
|000025b0| 61 74 6d 65 6e 74 20 6f | 66 20 70 72 6f 63 65 64 |atment o|f proced|
|000025c0| 75 72 65 73 20 61 6e 64 | 20 6c 69 74 65 72 61 6c |ures and| literal|
|000025d0| 73 3a 20 20 69 6d 70 6c | 65 6d 65 6e 74 61 74 69 |s: impl|ementati|
|000025e0| 6f 6e 73 20 61 72 65 20 | 66 72 65 65 0a 65 69 74 |ons are |free.eit|
|000025f0| 68 65 72 20 74 6f 20 64 | 65 74 65 63 74 20 6f 72 |her to d|etect or|
|00002600| 20 74 6f 20 66 61 69 6c | 20 74 6f 20 64 65 74 65 | to fail| to dete|
|00002610| 63 74 20 74 68 61 74 20 | 74 77 6f 20 70 72 6f 63 |ct that |two proc|
|00002620| 65 64 75 72 65 73 20 6f | 72 20 74 77 6f 20 6c 69 |edures o|r two li|
|00002630| 74 65 72 61 6c 73 0a 61 | 72 65 20 65 71 75 69 76 |terals.a|re equiv|
|00002640| 61 6c 65 6e 74 20 74 6f | 20 65 61 63 68 20 6f 74 |alent to| each ot|
|00002650| 68 65 72 2c 20 61 6e 64 | 20 63 61 6e 20 64 65 63 |her, and| can dec|
|00002660| 69 64 65 20 77 68 65 74 | 68 65 72 20 6f 72 20 6e |ide whet|her or n|
|00002670| 6f 74 20 74 6f 0a 6d 65 | 72 67 65 20 72 65 70 72 |ot to.me|rge repr|
|00002680| 65 73 65 6e 74 61 74 69 | 6f 6e 73 20 6f 66 20 65 |esentati|ons of e|
|00002690| 71 75 69 76 61 6c 65 6e | 74 20 6f 62 6a 65 63 74 |quivalen|t object|
|000026a0| 73 20 62 79 20 75 73 69 | 6e 67 20 74 68 65 20 73 |s by usi|ng the s|
|000026b0| 61 6d 65 20 70 6f 69 6e | 74 65 72 20 6f 72 0a 62 |ame poin|ter or.b|
|000026c0| 69 74 20 70 61 74 74 65 | 72 6e 20 74 6f 20 72 65 |it patte|rn to re|
|000026d0| 70 72 65 73 65 6e 74 20 | 62 6f 74 68 2e 0a 5c 65 |present |both..\e|
|000026e0| 6e 64 7b 72 61 74 69 6f | 6e 61 6c 65 7d 0a 0a 5c |nd{ratio|nale}..\|
|000026f0| 65 6e 64 7b 65 6e 74 72 | 79 7d 0a 0a 0a 5c 62 65 |end{entr|y}...\be|
|00002700| 67 69 6e 7b 65 6e 74 72 | 79 7d 7b 25 0a 5c 70 72 |gin{entr|y}{%.\pr|
|00002710| 6f 74 6f 7b 65 71 3f 7d | 7b 20 5c 76 61 72 69 7b |oto{eq?}|{ \vari{|
|00002720| 6f 62 6a 7d 20 5c 76 61 | 72 69 69 7b 6f 62 6a 7d |obj} \va|rii{obj}|
|00002730| 7d 7b 65 73 73 65 6e 74 | 69 61 6c 20 70 72 6f 63 |}{essent|ial proc|
|00002740| 65 64 75 72 65 7d 7d 0a | 0a 5c 69 64 65 7b 45 71 |edure}}.|.\ide{Eq|
|00002750| 3f 7d 5c 20 69 73 20 73 | 69 6d 69 6c 61 72 20 74 |?}\ is s|imilar t|
|00002760| 6f 20 5c 69 64 65 7b 65 | 71 76 3f 7d 5c 20 65 78 |o \ide{e|qv?}\ ex|
|00002770| 63 65 70 74 20 74 68 61 | 74 20 69 6e 20 73 6f 6d |cept tha|t in som|
|00002780| 65 20 63 61 73 65 73 20 | 69 74 20 69 73 0a 63 61 |e cases |it is.ca|
|00002790| 70 61 62 6c 65 20 6f 66 | 20 64 69 73 63 65 72 6e |pable of| discern|
|000027a0| 69 6e 67 20 64 69 73 74 | 69 6e 63 74 69 6f 6e 73 |ing dist|inctions|
|000027b0| 20 66 69 6e 65 72 20 74 | 68 61 6e 20 74 68 6f 73 | finer t|han thos|
|000027c0| 65 20 64 65 74 65 63 74 | 61 62 6c 65 20 62 79 0a |e detect|able by.|
|000027d0| 5c 69 64 65 7b 65 71 76 | 3f 7d 2e 0a 0a 5c 76 65 |\ide{eqv|?}...\ve|
|000027e0| 73 74 20 5c 69 64 65 7b | 45 71 3f 7d 5c 20 61 6e |st \ide{|Eq?}\ an|
|000027f0| 64 20 5c 69 64 65 7b 65 | 71 76 3f 7d 5c 20 61 72 |d \ide{e|qv?}\ ar|
|00002800| 65 20 67 75 61 72 61 6e | 74 65 65 64 20 74 6f 20 |e guaran|teed to |
|00002810| 68 61 76 65 20 74 68 65 | 20 73 61 6d 65 0a 62 65 |have the| same.be|
|00002820| 68 61 76 69 6f 72 20 6f | 6e 20 73 79 6d 62 6f 6c |havior o|n symbol|
|00002830| 73 2c 20 62 6f 6f 6c 65 | 61 6e 73 2c 20 74 68 65 |s, boole|ans, the|
|00002840| 20 65 6d 70 74 79 20 6c | 69 73 74 2c 20 70 61 69 | empty l|ist, pai|
|00002850| 72 73 2c 20 61 6e 64 20 | 6e 6f 6e 2d 65 6d 70 74 |rs, and |non-empt|
|00002860| 79 0a 73 74 72 69 6e 67 | 73 20 61 6e 64 20 76 65 |y.string|s and ve|
|00002870| 63 74 6f 72 73 2e 20 20 | 5c 69 64 65 7b 45 71 3f |ctors. |\ide{Eq?|
|00002880| 7d 27 73 20 62 65 68 61 | 76 69 6f 72 20 6f 6e 20 |}'s beha|vior on |
|00002890| 6e 75 6d 62 65 72 73 20 | 61 6e 64 20 63 68 61 72 |numbers |and char|
|000028a0| 61 63 74 65 72 73 20 69 | 73 0a 69 6d 70 6c 65 6d |acters i|s.implem|
|000028b0| 65 6e 74 61 74 69 6f 6e | 2d 64 65 70 65 6e 64 65 |entation|-depende|
|000028c0| 6e 74 2c 20 62 75 74 20 | 69 74 20 77 69 6c 6c 20 |nt, but |it will |
|000028d0| 61 6c 77 61 79 73 20 72 | 65 74 75 72 6e 20 65 69 |always r|eturn ei|
|000028e0| 74 68 65 72 20 74 72 75 | 65 20 6f 72 0a 66 61 6c |ther tru|e or.fal|
|000028f0| 73 65 2c 20 61 6e 64 20 | 77 69 6c 6c 20 72 65 74 |se, and |will ret|
|00002900| 75 72 6e 20 74 72 75 65 | 20 6f 6e 6c 79 20 77 68 |urn true| only wh|
|00002910| 65 6e 20 5c 69 64 65 7b | 65 71 76 3f 7d 5c 20 77 |en \ide{|eqv?}\ w|
|00002920| 6f 75 6c 64 20 61 6c 73 | 6f 20 72 65 74 75 72 6e |ould als|o return|
|00002930| 0a 74 72 75 65 2e 20 20 | 5c 69 64 65 7b 45 71 3f |.true. |\ide{Eq?|
|00002940| 7d 20 6d 61 79 20 61 6c | 73 6f 20 62 65 68 61 76 |} may al|so behav|
|00002950| 65 20 64 69 66 66 65 72 | 65 6e 74 6c 79 20 66 72 |e differ|ently fr|
|00002960| 6f 6d 20 5c 69 64 65 7b | 65 71 76 3f 7d 20 6f 6e |om \ide{|eqv?} on|
|00002970| 20 65 6d 70 74 79 0a 76 | 65 63 74 6f 72 73 20 61 | empty.v|ectors a|
|00002980| 6e 64 20 65 6d 70 74 79 | 20 73 74 72 69 6e 67 73 |nd empty| strings|
|00002990| 2e 0a 0a 5c 62 65 67 69 | 6e 7b 73 63 68 65 6d 65 |...\begi|n{scheme|
|000029a0| 7d 0a 28 65 71 3f 20 27 | 61 20 27 61 29 20 20 20 |}.(eq? '|a 'a) |
|000029b0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000029c0| 20 20 5c 65 76 20 20 5c | 73 63 68 74 72 75 65 0a | \ev \|schtrue.|
|000029d0| 28 65 71 3f 20 27 28 61 | 29 20 27 28 61 29 29 20 |(eq? '(a|) '(a)) |
|000029e0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000029f0| 5c 65 76 20 20 5c 75 6e | 73 70 65 63 69 66 69 65 |\ev \un|specifie|
|00002a00| 64 0a 28 65 71 3f 20 28 | 6c 69 73 74 20 27 61 29 |d.(eq? (|list 'a)|
|00002a10| 20 28 6c 69 73 74 20 27 | 61 29 29 20 20 20 20 20 | (list '|a)) |
|00002a20| 20 20 5c 65 76 20 20 5c | 73 63 68 66 61 6c 73 65 | \ev \|schfalse|
|00002a30| 0a 28 65 71 3f 20 22 61 | 22 20 22 61 22 29 20 20 |.(eq? "a|" "a") |
|00002a40| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002a50| 20 5c 65 76 20 20 5c 75 | 6e 73 70 65 63 69 66 69 | \ev \u|nspecifi|
|00002a60| 65 64 0a 28 65 71 3f 20 | 22 22 20 22 22 29 20 20 |ed.(eq? |"" "") |
|00002a70| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002a80| 20 20 20 5c 65 76 20 20 | 5c 75 6e 73 70 65 63 69 | \ev |\unspeci|
|00002a90| 66 69 65 64 0a 28 65 71 | 3f 20 27 28 29 20 27 28 |fied.(eq|? '() '(|
|00002aa0| 29 29 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |)) | |
|00002ab0| 20 20 20 20 20 5c 65 76 | 20 20 5c 73 63 68 74 72 | \ev| \schtr|
|00002ac0| 75 65 0a 28 65 71 3f 20 | 32 20 32 29 20 20 20 20 |ue.(eq? |2 2) |
|00002ad0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002ae0| 20 20 20 5c 65 76 20 20 | 5c 75 6e 73 70 65 63 69 | \ev |\unspeci|
|00002af0| 66 69 65 64 0a 28 65 71 | 3f 20 5c 23 5c 62 61 63 |fied.(eq|? \#\bac|
|00002b00| 6b 77 68 61 63 6b 7b 7d | 41 20 5c 23 5c 62 61 63 |kwhack{}|A \#\bac|
|00002b10| 6b 77 68 61 63 6b 7b 7d | 41 29 20 5c 65 76 20 20 |kwhack{}|A) \ev |
|00002b20| 5c 75 6e 73 70 65 63 69 | 66 69 65 64 0a 28 65 71 |\unspeci|fied.(eq|
|00002b30| 3f 20 63 61 72 20 63 61 | 72 29 20 20 20 20 20 20 |? car ca|r) |
|00002b40| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 5c 65 76 | | \ev|
|00002b50| 20 20 5c 73 63 68 74 72 | 75 65 0a 28 6c 65 74 20 | \schtr|ue.(let |
|00002b60| 28 28 6e 20 28 2b 20 32 | 20 33 29 29 29 0a 20 20 |((n (+ 2| 3))). |
|00002b70| 28 65 71 3f 20 6e 20 6e | 29 29 20 20 20 20 20 20 |(eq? n n|)) |
|00002b80| 5c 65 76 20 20 5c 75 6e | 73 70 65 63 69 66 69 65 |\ev \un|specifie|
|00002b90| 64 0a 28 6c 65 74 20 28 | 28 78 20 27 28 61 29 29 |d.(let (|(x '(a))|
|00002ba0| 29 0a 20 20 28 65 71 3f | 20 78 20 78 29 29 20 20 |). (eq?| x x)) |
|00002bb0| 20 20 20 20 5c 65 76 20 | 20 5c 73 63 68 74 72 75 | \ev | \schtru|
|00002bc0| 65 0a 28 6c 65 74 20 28 | 28 78 20 27 5c 23 28 29 |e.(let (|(x '\#()|
|00002bd0| 29 29 0a 20 20 28 65 71 | 3f 20 78 20 78 29 29 20 |)). (eq|? x x)) |
|00002be0| 20 20 20 20 20 5c 65 76 | 20 20 5c 73 63 68 74 72 | \ev| \schtr|
|00002bf0| 75 65 0a 28 6c 65 74 20 | 28 28 70 20 28 6c 61 6d |ue.(let |((p (lam|
|00002c00| 62 64 61 20 28 78 29 20 | 78 29 29 29 0a 20 20 28 |bda (x) |x))). (|
|00002c10| 65 71 3f 20 70 20 70 29 | 29 20 20 20 20 20 20 5c |eq? p p)|) \|
|00002c20| 65 76 20 20 5c 73 63 68 | 74 72 75 65 25 0a 5c 65 |ev \sch|true%.\e|
|00002c30| 6e 64 7b 73 63 68 65 6d | 65 7d 0a 0a 5c 74 6f 64 |nd{schem|e}..\tod|
|00002c40| 6f 7b 4e 65 65 64 73 20 | 74 6f 20 62 65 20 65 78 |o{Needs |to be ex|
|00002c50| 70 6c 61 69 6e 65 64 20 | 62 65 74 74 65 72 20 61 |plained |better a|
|00002c60| 62 6f 76 65 2e 20 20 48 | 6f 77 20 63 61 6e 20 74 |bove. H|ow can t|
|00002c70| 68 69 73 20 62 65 20 6d | 61 64 65 20 74 6f 20 62 |his be m|ade to b|
|00002c80| 65 0a 6e 6f 74 20 63 6f | 6e 66 75 73 69 6e 67 3f |e.not co|nfusing?|
|00002c90| 20 20 41 20 74 61 62 6c | 65 20 6d 61 79 62 65 3f | A tabl|e maybe?|
|00002ca0| 7d 0a 0a 5c 62 65 67 69 | 6e 7b 72 61 74 69 6f 6e |}..\begi|n{ration|
|00002cb0| 61 6c 65 7d 20 49 74 20 | 77 69 6c 6c 20 75 73 75 |ale} It |will usu|
|00002cc0| 61 6c 6c 79 20 62 65 20 | 70 6f 73 73 69 62 6c 65 |ally be |possible|
|00002cd0| 20 74 6f 20 69 6d 70 6c | 65 6d 65 6e 74 20 5c 69 | to impl|ement \i|
|00002ce0| 64 65 7b 65 71 3f 7d 5c | 20 6d 75 63 68 0a 6d 6f |de{eq?}\| much.mo|
|00002cf0| 72 65 20 65 66 66 69 63 | 69 65 6e 74 6c 79 20 74 |re effic|iently t|
|00002d00| 68 61 6e 20 5c 69 64 65 | 7b 65 71 76 3f 7d 2c 20 |han \ide|{eqv?}, |
|00002d10| 66 6f 72 20 65 78 61 6d | 70 6c 65 2c 20 61 73 20 |for exam|ple, as |
|00002d20| 61 20 73 69 6d 70 6c 65 | 20 70 6f 69 6e 74 65 72 |a simple| pointer|
|00002d30| 0a 63 6f 6d 70 61 72 69 | 73 6f 6e 20 69 6e 73 74 |.compari|son inst|
|00002d40| 65 61 64 20 6f 66 20 61 | 73 20 73 6f 6d 65 20 6d |ead of a|s some m|
|00002d50| 6f 72 65 20 63 6f 6d 70 | 6c 69 63 61 74 65 64 20 |ore comp|licated |
|00002d60| 6f 70 65 72 61 74 69 6f | 6e 2e 20 20 4f 6e 65 20 |operatio|n. One |
|00002d70| 72 65 61 73 6f 6e 20 69 | 73 0a 74 68 61 74 20 69 |reason i|s.that i|
|00002d80| 74 20 6d 61 79 20 6e 6f | 74 20 62 65 20 70 6f 73 |t may no|t be pos|
|00002d90| 73 69 62 6c 65 20 74 6f | 20 63 6f 6d 70 75 74 65 |sible to| compute|
|00002da0| 20 5c 69 64 65 7b 65 71 | 76 3f 7d 5c 20 6f 66 20 | \ide{eq|v?}\ of |
|00002db0| 74 77 6f 20 6e 75 6d 62 | 65 72 73 20 69 6e 0a 63 |two numb|ers in.c|
|00002dc0| 6f 6e 73 74 61 6e 74 20 | 74 69 6d 65 2c 20 77 68 |onstant |time, wh|
|00002dd0| 65 72 65 61 73 20 5c 69 | 64 65 7b 65 71 3f 7d 5c |ereas \i|de{eq?}\|
|00002de0| 20 69 6d 70 6c 65 6d 65 | 6e 74 65 64 20 61 73 20 | impleme|nted as |
|00002df0| 70 6f 69 6e 74 65 72 20 | 63 6f 6d 70 61 72 69 73 |pointer |comparis|
|00002e00| 6f 6e 20 77 69 6c 6c 0a | 61 6c 77 61 79 73 20 66 |on will.|always f|
|00002e10| 69 6e 69 73 68 20 69 6e | 20 63 6f 6e 73 74 61 6e |inish in| constan|
|00002e20| 74 20 74 69 6d 65 2e 20 | 20 5c 69 64 65 7b 45 71 |t time. | \ide{Eq|
|00002e30| 3f 7d 5c 20 6d 61 79 20 | 62 65 20 75 73 65 64 20 |?}\ may |be used |
|00002e40| 6c 69 6b 65 20 5c 69 64 | 65 7b 65 71 76 3f 7d 5c |like \id|e{eqv?}\|
|00002e50| 0a 69 6e 20 61 70 70 6c | 69 63 61 74 69 6f 6e 73 |.in appl|ications|
|00002e60| 20 75 73 69 6e 67 20 70 | 72 6f 63 65 64 75 72 65 | using p|rocedure|
|00002e70| 73 20 74 6f 20 69 6d 70 | 6c 65 6d 65 6e 74 20 6f |s to imp|lement o|
|00002e80| 62 6a 65 63 74 73 20 77 | 69 74 68 20 73 74 61 74 |bjects w|ith stat|
|00002e90| 65 20 73 69 6e 63 65 0a | 69 74 20 6f 62 65 79 73 |e since.|it obeys|
|00002ea0| 20 74 68 65 20 73 61 6d | 65 20 63 6f 6e 73 74 72 | the sam|e constr|
|00002eb0| 61 69 6e 74 73 20 61 73 | 20 5c 69 64 65 7b 65 71 |aints as| \ide{eq|
|00002ec0| 76 3f 7d 2e 0a 5c 65 6e | 64 7b 72 61 74 69 6f 6e |v?}..\en|d{ration|
|00002ed0| 61 6c 65 7d 0a 0a 5c 65 | 6e 64 7b 65 6e 74 72 79 |ale}..\e|nd{entry|
|00002ee0| 7d 0a 0a 0a 5c 62 65 67 | 69 6e 7b 65 6e 74 72 79 |}...\beg|in{entry|
|00002ef0| 7d 7b 25 0a 5c 70 72 6f | 74 6f 7b 65 71 75 61 6c |}{%.\pro|to{equal|
|00002f00| 3f 7d 7b 20 5c 76 61 72 | 69 7b 6f 62 6a 7d 20 5c |?}{ \var|i{obj} \|
|00002f10| 76 61 72 69 69 7b 6f 62 | 6a 7d 7d 7b 65 73 73 65 |varii{ob|j}}{esse|
|00002f20| 6e 74 69 61 6c 20 70 72 | 6f 63 65 64 75 72 65 7d |ntial pr|ocedure}|
|00002f30| 7d 0a 0a 5c 69 64 65 7b | 45 71 75 61 6c 3f 7d 20 |}..\ide{|Equal?} |
|00002f40| 72 65 63 75 72 73 69 76 | 65 6c 79 20 63 6f 6d 70 |recursiv|ely comp|
|00002f50| 61 72 65 73 20 74 68 65 | 20 63 6f 6e 74 65 6e 74 |ares the| content|
|00002f60| 73 20 6f 66 20 70 61 69 | 72 73 2c 20 76 65 63 74 |s of pai|rs, vect|
|00002f70| 6f 72 73 2c 20 61 6e 64 | 0a 73 74 72 69 6e 67 73 |ors, and|.strings|
|00002f80| 2c 20 61 70 70 6c 79 69 | 6e 67 20 5c 69 64 65 7b |, applyi|ng \ide{|
|00002f90| 65 71 76 3f 7d 20 6f 6e | 20 6f 74 68 65 72 20 6f |eqv?} on| other o|
|00002fa0| 62 6a 65 63 74 73 20 73 | 75 63 68 20 61 73 20 6e |bjects s|uch as n|
|00002fb0| 75 6d 62 65 72 73 20 61 | 6e 64 20 73 79 6d 62 6f |umbers a|nd symbo|
|00002fc0| 6c 73 2e 0a 41 20 72 75 | 6c 65 20 6f 66 20 74 68 |ls..A ru|le of th|
|00002fd0| 75 6d 62 20 69 73 20 74 | 68 61 74 20 6f 62 6a 65 |umb is t|hat obje|
|00002fe0| 63 74 73 20 61 72 65 20 | 67 65 6e 65 72 61 6c 6c |cts are |generall|
|00002ff0| 79 20 5c 69 64 65 7b 65 | 71 75 61 6c 3f 7d 20 69 |y \ide{e|qual?} i|
|00003000| 66 20 74 68 65 79 20 70 | 72 69 6e 74 0a 74 68 65 |f they p|rint.the|
|00003010| 20 73 61 6d 65 2e 20 20 | 5c 69 64 65 7b 45 71 75 | same. |\ide{Equ|
|00003020| 61 6c 3f 7d 5c 20 6d 61 | 79 20 66 61 69 6c 20 74 |al?}\ ma|y fail t|
|00003030| 6f 20 74 65 72 6d 69 6e | 61 74 65 20 69 66 20 69 |o termin|ate if i|
|00003040| 74 73 20 61 72 67 75 6d | 65 6e 74 73 20 61 72 65 |ts argum|ents are|
|00003050| 0a 63 69 72 63 75 6c 61 | 72 20 64 61 74 61 20 73 |.circula|r data s|
|00003060| 74 72 75 63 74 75 72 65 | 73 2e 0a 0a 5c 62 65 67 |tructure|s...\beg|
|00003070| 69 6e 7b 73 63 68 65 6d | 65 7d 0a 28 65 71 75 61 |in{schem|e}.(equa|
|00003080| 6c 3f 20 27 61 20 27 61 | 29 20 20 20 20 20 20 20 |l? 'a 'a|) |
|00003090| 20 20 20 20 20 20 20 20 | 20 20 20 5c 65 76 20 20 | | \ev |
|000030a0| 5c 73 63 68 74 72 75 65 | 0a 28 65 71 75 61 6c 3f |\schtrue|.(equal?|
|000030b0| 20 27 28 61 29 20 27 28 | 61 29 29 20 20 20 20 20 | '(a) '(|a)) |
|000030c0| 20 20 20 20 20 20 20 20 | 20 5c 65 76 20 20 5c 73 | | \ev \s|
|000030d0| 63 68 74 72 75 65 0a 28 | 65 71 75 61 6c 3f 20 27 |chtrue.(|equal? '|
|000030e0| 28 61 20 28 62 29 20 63 | 29 0a 20 20 20 20 20 20 |(a (b) c|). |
|000030f0| 20 20 27 28 61 20 28 62 | 29 20 63 29 29 20 20 20 | '(a (b|) c)) |
|00003100| 20 20 20 20 20 20 20 20 | 20 20 5c 65 76 20 20 5c | | \ev \|
|00003110| 73 63 68 74 72 75 65 0a | 28 65 71 75 61 6c 3f 20 |schtrue.|(equal? |
|00003120| 22 61 62 63 22 20 22 61 | 62 63 22 29 20 20 20 20 |"abc" "a|bc") |
|00003130| 20 20 20 20 20 20 20 20 | 5c 65 76 20 20 5c 73 63 | |\ev \sc|
|00003140| 68 74 72 75 65 0a 28 65 | 71 75 61 6c 3f 20 32 20 |htrue.(e|qual? 2 |
|00003150| 32 29 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |2) | |
|00003160| 20 20 20 20 20 20 5c 65 | 76 20 20 5c 73 63 68 74 | \e|v \scht|
|00003170| 72 75 65 0a 28 65 71 75 | 61 6c 3f 20 28 6d 61 6b |rue.(equ|al? (mak|
|00003180| 65 2d 76 65 63 74 6f 72 | 20 35 20 27 61 29 0a 20 |e-vector| 5 'a). |
|00003190| 20 20 20 20 20 20 20 28 | 6d 61 6b 65 2d 76 65 63 | (|make-vec|
|000031a0| 74 6f 72 20 35 20 27 61 | 29 29 20 20 20 20 20 5c |tor 5 'a|)) \|
|000031b0| 65 76 20 20 5c 73 63 68 | 74 72 75 65 0a 28 65 71 |ev \sch|true.(eq|
|000031c0| 75 61 6c 3f 20 28 6c 61 | 6d 62 64 61 20 28 78 29 |ual? (la|mbda (x)|
|000031d0| 20 78 29 0a 20 20 20 20 | 20 20 20 20 28 6c 61 6d | x). | (lam|
|000031e0| 62 64 61 20 28 79 29 20 | 79 29 29 20 20 5c 65 76 |bda (y) |y)) \ev|
|000031f0| 20 20 5c 75 6e 73 70 65 | 63 69 66 69 65 64 25 0a | \unspe|cified%.|
|00003200| 5c 65 6e 64 7b 73 63 68 | 65 6d 65 7d 0a 0a 5c 65 |\end{sch|eme}..\e|
|00003210| 6e 64 7b 65 6e 74 72 79 | 7d 0a 0a 0a 5c 73 65 63 |nd{entry|}...\sec|
|00003220| 74 69 6f 6e 7b 50 61 69 | 72 73 20 61 6e 64 20 6c |tion{Pai|rs and l|
|00003230| 69 73 74 73 7d 0a 5c 6c | 61 62 65 6c 7b 6c 69 73 |ists}.\l|abel{lis|
|00003240| 74 73 65 63 74 69 6f 6e | 7d 0a 0a 41 20 5c 64 65 |tsection|}..A \de|
|00003250| 66 69 6e 69 6e 67 7b 70 | 61 69 72 7d 20 28 73 6f |fining{p|air} (so|
|00003260| 6d 65 74 69 6d 65 73 20 | 63 61 6c 6c 65 64 20 61 |metimes |called a|
|00003270| 20 5c 64 65 66 69 6e 69 | 6e 67 7b 64 6f 74 74 65 | \defini|ng{dotte|
|00003280| 64 20 70 61 69 72 7d 29 | 20 69 73 20 61 0a 72 65 |d pair})| is a.re|
|00003290| 63 6f 72 64 20 73 74 72 | 75 63 74 75 72 65 20 77 |cord str|ucture w|
|000032a0| 69 74 68 20 74 77 6f 20 | 66 69 65 6c 64 73 20 63 |ith two |fields c|
|000032b0| 61 6c 6c 65 64 20 74 68 | 65 20 63 61 72 20 61 6e |alled th|e car an|
|000032c0| 64 20 63 64 72 20 66 69 | 65 6c 64 73 20 28 66 6f |d cdr fi|elds (fo|
|000032d0| 72 0a 68 69 73 74 6f 72 | 69 63 61 6c 20 72 65 61 |r.histor|ical rea|
|000032e0| 73 6f 6e 73 29 2e 20 20 | 50 61 69 72 73 20 61 72 |sons). |Pairs ar|
|000032f0| 65 20 63 72 65 61 74 65 | 64 20 62 79 20 74 68 65 |e create|d by the|
|00003300| 20 70 72 6f 63 65 64 75 | 72 65 20 5c 69 64 65 7b | procedu|re \ide{|
|00003310| 63 6f 6e 73 7d 2e 0a 54 | 68 65 20 63 61 72 20 61 |cons}..T|he car a|
|00003320| 6e 64 20 63 64 72 20 66 | 69 65 6c 64 73 20 61 72 |nd cdr f|ields ar|
|00003330| 65 20 61 63 63 65 73 73 | 65 64 20 62 79 20 74 68 |e access|ed by th|
|00003340| 65 20 70 72 6f 63 65 64 | 75 72 65 73 20 5c 69 64 |e proced|ures \id|
|00003350| 65 7b 63 61 72 7d 20 61 | 6e 64 0a 5c 69 64 65 7b |e{car} a|nd.\ide{|
|00003360| 63 64 72 7d 2e 20 20 54 | 68 65 20 63 61 72 20 61 |cdr}. T|he car a|
|00003370| 6e 64 20 63 64 72 20 66 | 69 65 6c 64 73 20 61 72 |nd cdr f|ields ar|
|00003380| 65 20 61 73 73 69 67 6e | 65 64 20 62 79 20 74 68 |e assign|ed by th|
|00003390| 65 20 70 72 6f 63 65 64 | 75 72 65 73 0a 5c 69 64 |e proced|ures.\id|
|000033a0| 65 7b 73 65 74 2d 63 61 | 72 21 7d 5c 20 61 6e 64 |e{set-ca|r!}\ and|
|000033b0| 20 5c 69 64 65 7b 73 65 | 74 2d 63 64 72 21 7d 2e | \ide{se|t-cdr!}.|
|000033c0| 0a 0a 50 61 69 72 73 20 | 61 72 65 20 75 73 65 64 |..Pairs |are used|
|000033d0| 20 70 72 69 6d 61 72 69 | 6c 79 20 74 6f 20 72 65 | primari|ly to re|
|000033e0| 70 72 65 73 65 6e 74 20 | 6c 69 73 74 73 2e 20 20 |present |lists. |
|000033f0| 41 20 6c 69 73 74 20 63 | 61 6e 0a 62 65 20 64 65 |A list c|an.be de|
|00003400| 66 69 6e 65 64 20 72 65 | 63 75 72 73 69 76 65 6c |fined re|cursivel|
|00003410| 79 20 61 73 20 65 69 74 | 68 65 72 20 74 68 65 20 |y as eit|her the |
|00003420| 65 6d 70 74 79 20 6c 69 | 73 74 5c 69 6e 64 65 78 |empty li|st\index|
|00003430| 7b 65 6d 70 74 79 20 6c | 69 73 74 7d 20 6f 72 20 |{empty l|ist} or |
|00003440| 61 20 70 61 69 72 20 77 | 68 6f 73 65 0a 63 64 72 |a pair w|hose.cdr|
|00003450| 20 69 73 20 61 20 6c 69 | 73 74 2e 20 20 4d 6f 72 | is a li|st. Mor|
|00003460| 65 20 70 72 65 63 69 73 | 65 6c 79 2c 20 74 68 65 |e precis|ely, the|
|00003470| 20 73 65 74 20 6f 66 20 | 6c 69 73 74 73 20 69 73 | set of |lists is|
|00003480| 20 64 65 66 69 6e 65 64 | 20 61 73 20 74 68 65 20 | defined| as the |
|00003490| 73 6d 61 6c 6c 65 73 74 | 0a 73 65 74 20 5c 76 61 |smallest|.set \va|
|000034a0| 72 7b 58 7d 20 73 75 63 | 68 20 74 68 61 74 0a 0a |r{X} suc|h that..|
|000034b0| 5c 62 65 67 69 6e 7b 69 | 74 65 6d 69 7a 65 7d 0a |\begin{i|temize}.|
|000034c0| 5c 69 74 65 6d 20 54 68 | 65 20 65 6d 70 74 79 20 |\item Th|e empty |
|000034d0| 6c 69 73 74 20 69 73 20 | 69 6e 20 5c 76 61 72 7b |list is |in \var{|
|000034e0| 58 7d 2e 0a 5c 69 74 65 | 6d 20 49 66 20 5c 76 61 |X}..\ite|m If \va|
|000034f0| 72 7b 6c 69 73 74 7d 20 | 69 73 20 69 6e 20 5c 76 |r{list} |is in \v|
|00003500| 61 72 7b 58 7d 2c 20 74 | 68 65 6e 20 61 6e 79 20 |ar{X}, t|hen any |
|00003510| 70 61 69 72 20 77 68 6f | 73 65 20 63 64 72 20 66 |pair who|se cdr f|
|00003520| 69 65 6c 64 20 63 6f 6e | 74 61 69 6e 73 0a 20 20 |ield con|tains. |
|00003530| 20 20 20 20 5c 76 61 72 | 7b 6c 69 73 74 7d 20 69 | \var|{list} i|
|00003540| 73 20 61 6c 73 6f 20 69 | 6e 20 5c 76 61 72 7b 58 |s also i|n \var{X|
|00003550| 7d 2e 0a 5c 65 6e 64 7b | 69 74 65 6d 69 7a 65 7d |}..\end{|itemize}|
|00003560| 0a 0a 54 68 65 20 6f 62 | 6a 65 63 74 73 20 69 6e |..The ob|jects in|
|00003570| 20 74 68 65 20 63 61 72 | 20 66 69 65 6c 64 73 20 | the car| fields |
|00003580| 6f 66 20 73 75 63 63 65 | 73 73 69 76 65 20 70 61 |of succe|ssive pa|
|00003590| 69 72 73 20 6f 66 20 61 | 20 6c 69 73 74 20 61 72 |irs of a| list ar|
|000035a0| 65 20 74 68 65 0a 65 6c | 65 6d 65 6e 74 73 20 6f |e the.el|ements o|
|000035b0| 66 20 74 68 65 20 6c 69 | 73 74 2e 20 20 46 6f 72 |f the li|st. For|
|000035c0| 20 65 78 61 6d 70 6c 65 | 2c 20 61 20 74 77 6f 2d | example|, a two-|
|000035d0| 65 6c 65 6d 65 6e 74 20 | 6c 69 73 74 20 69 73 20 |element |list is |
|000035e0| 61 20 70 61 69 72 20 77 | 68 6f 73 65 20 63 61 72 |a pair w|hose car|
|000035f0| 0a 69 73 20 74 68 65 20 | 66 69 72 73 74 20 65 6c |.is the |first el|
|00003600| 65 6d 65 6e 74 20 61 6e | 64 20 77 68 6f 73 65 20 |ement an|d whose |
|00003610| 63 64 72 20 69 73 20 61 | 20 70 61 69 72 20 77 68 |cdr is a| pair wh|
|00003620| 6f 73 65 20 63 61 72 20 | 69 73 20 74 68 65 20 73 |ose car |is the s|
|00003630| 65 63 6f 6e 64 20 65 6c | 65 6d 65 6e 74 0a 61 6e |econd el|ement.an|
|00003640| 64 20 77 68 6f 73 65 20 | 63 64 72 20 69 73 20 74 |d whose |cdr is t|
|00003650| 68 65 20 65 6d 70 74 79 | 20 6c 69 73 74 2e 20 20 |he empty| list. |
|00003660| 54 68 65 20 6c 65 6e 67 | 74 68 20 6f 66 20 61 20 |The leng|th of a |
|00003670| 6c 69 73 74 20 69 73 20 | 74 68 65 20 6e 75 6d 62 |list is |the numb|
|00003680| 65 72 20 6f 66 0a 65 6c | 65 6d 65 6e 74 73 2c 20 |er of.el|ements, |
|00003690| 77 68 69 63 68 20 69 73 | 20 74 68 65 20 73 61 6d |which is| the sam|
|000036a0| 65 20 61 73 20 74 68 65 | 20 6e 75 6d 62 65 72 20 |e as the| number |
|000036b0| 6f 66 20 70 61 69 72 73 | 2e 0a 0a 54 68 65 20 65 |of pairs|...The e|
|000036c0| 6d 70 74 79 20 6c 69 73 | 74 5c 6d 61 69 6e 69 6e |mpty lis|t\mainin|
|000036d0| 64 65 78 7b 65 6d 70 74 | 79 20 6c 69 73 74 7d 20 |dex{empt|y list} |
|000036e0| 69 73 20 61 20 73 70 65 | 63 69 61 6c 20 6f 62 6a |is a spe|cial obj|
|000036f0| 65 63 74 20 6f 66 20 69 | 74 73 20 6f 77 6e 20 74 |ect of i|ts own t|
|00003700| 79 70 65 0a 28 69 74 20 | 69 73 20 6e 6f 74 20 61 |ype.(it |is not a|
|00003710| 20 70 61 69 72 29 3b 20 | 69 74 20 68 61 73 20 6e | pair); |it has n|
|00003720| 6f 20 65 6c 65 6d 65 6e | 74 73 20 61 6e 64 20 69 |o elemen|ts and i|
|00003730| 74 73 20 6c 65 6e 67 74 | 68 20 69 73 20 7a 65 72 |ts lengt|h is zer|
|00003740| 6f 2e 0a 0a 5c 62 65 67 | 69 6e 7b 6e 6f 74 65 7d |o...\beg|in{note}|
|00003750| 0a 54 68 65 20 61 62 6f | 76 65 20 64 65 66 69 6e |.The abo|ve defin|
|00003760| 69 74 69 6f 6e 73 20 69 | 6d 70 6c 79 20 74 68 61 |itions i|mply tha|
|00003770| 74 20 61 6c 6c 20 6c 69 | 73 74 73 20 68 61 76 65 |t all li|sts have|
|00003780| 20 66 69 6e 69 74 65 20 | 6c 65 6e 67 74 68 20 61 | finite |length a|
|00003790| 6e 64 20 61 72 65 0a 74 | 65 72 6d 69 6e 61 74 65 |nd are.t|erminate|
|000037a0| 64 20 62 79 20 74 68 65 | 20 65 6d 70 74 79 20 6c |d by the| empty l|
|000037b0| 69 73 74 2e 0a 5c 65 6e | 64 7b 6e 6f 74 65 7d 0a |ist..\en|d{note}.|
|000037c0| 0a 54 68 65 20 6d 6f 73 | 74 20 67 65 6e 65 72 61 |.The mos|t genera|
|000037d0| 6c 20 6e 6f 74 61 74 69 | 6f 6e 20 28 65 78 74 65 |l notati|on (exte|
|000037e0| 72 6e 61 6c 20 72 65 70 | 72 65 73 65 6e 74 61 74 |rnal rep|resentat|
|000037f0| 69 6f 6e 29 20 66 6f 72 | 20 53 63 68 65 6d 65 20 |ion) for| Scheme |
|00003800| 70 61 69 72 73 20 69 73 | 0a 74 68 65 20 60 60 64 |pairs is|.the ``d|
|00003810| 6f 74 74 65 64 27 27 20 | 6e 6f 74 61 74 69 6f 6e |otted'' |notation|
|00003820| 20 5c 68 62 6f 78 7b 5c | 63 66 20 28 5c 76 61 72 | \hbox{\|cf (\var|
|00003830| 69 7b 63 7d 20 2e 5c 20 | 5c 76 61 72 69 69 7b 63 |i{c} .\ |\varii{c|
|00003840| 7d 29 7d 20 77 68 65 72 | 65 0a 5c 76 61 72 69 7b |})} wher|e.\vari{|
|00003850| 63 7d 20 69 73 20 74 68 | 65 20 76 61 6c 75 65 20 |c} is th|e value |
|00003860| 6f 66 20 74 68 65 20 63 | 61 72 20 66 69 65 6c 64 |of the c|ar field|
|00003870| 20 61 6e 64 20 5c 76 61 | 72 69 69 7b 63 7d 20 69 | and \va|rii{c} i|
|00003880| 73 20 74 68 65 20 76 61 | 6c 75 65 20 6f 66 20 74 |s the va|lue of t|
|00003890| 68 65 0a 63 64 72 20 66 | 69 65 6c 64 2e 20 20 46 |he.cdr f|ield. F|
|000038a0| 6f 72 20 65 78 61 6d 70 | 6c 65 20 7b 5c 63 66 20 |or examp|le {\cf |
|000038b0| 28 34 20 2e 5c 20 35 29 | 7d 20 69 73 20 61 20 70 |(4 .\ 5)|} is a p|
|000038c0| 61 69 72 20 77 68 6f 73 | 65 20 63 61 72 20 69 73 |air whos|e car is|
|000038d0| 20 34 20 61 6e 64 20 77 | 68 6f 73 65 0a 63 64 72 | 4 and w|hose.cdr|
|000038e0| 20 69 73 20 35 2e 20 20 | 4e 6f 74 65 20 74 68 61 | is 5. |Note tha|
|000038f0| 74 20 7b 5c 63 66 20 28 | 34 20 2e 5c 20 35 29 7d |t {\cf (|4 .\ 5)}|
|00003900| 20 69 73 20 74 68 65 20 | 65 78 74 65 72 6e 61 6c | is the |external|
|00003910| 20 72 65 70 72 65 73 65 | 6e 74 61 74 69 6f 6e 20 | represe|ntation |
|00003920| 6f 66 20 61 0a 70 61 69 | 72 2c 20 6e 6f 74 20 61 |of a.pai|r, not a|
|00003930| 6e 20 65 78 70 72 65 73 | 73 69 6f 6e 20 74 68 61 |n expres|sion tha|
|00003940| 74 20 65 76 61 6c 75 61 | 74 65 73 20 74 6f 20 61 |t evalua|tes to a|
|00003950| 20 70 61 69 72 2e 0a 0a | 41 20 6d 6f 72 65 20 73 | pair...|A more s|
|00003960| 74 72 65 61 6d 6c 69 6e | 65 64 20 6e 6f 74 61 74 |treamlin|ed notat|
|00003970| 69 6f 6e 20 63 61 6e 20 | 62 65 20 75 73 65 64 20 |ion can |be used |
|00003980| 66 6f 72 20 6c 69 73 74 | 73 3a 20 74 68 65 20 65 |for list|s: the e|
|00003990| 6c 65 6d 65 6e 74 73 20 | 6f 66 20 74 68 65 0a 6c |lements |of the.l|
|000039a0| 69 73 74 20 61 72 65 20 | 73 69 6d 70 6c 79 20 65 |ist are |simply e|
|000039b0| 6e 63 6c 6f 73 65 64 20 | 69 6e 20 70 61 72 65 6e |nclosed |in paren|
|000039c0| 74 68 65 73 65 73 20 61 | 6e 64 20 73 65 70 61 72 |theses a|nd separ|
|000039d0| 61 74 65 64 20 62 79 20 | 73 70 61 63 65 73 2e 20 |ated by |spaces. |
|000039e0| 20 54 68 65 0a 65 6d 70 | 74 79 20 6c 69 73 74 5c | The.emp|ty list\|
|000039f0| 69 6e 64 65 78 7b 65 6d | 70 74 79 20 6c 69 73 74 |index{em|pty list|
|00003a00| 7d 20 69 73 20 77 72 69 | 74 74 65 6e 20 7b 5c 74 |} is wri|tten {\t|
|00003a10| 74 28 29 7d 20 2e 20 20 | 46 6f 72 20 65 78 61 6d |t()} . |For exam|
|00003a20| 70 6c 65 2c 0a 0a 5c 62 | 65 67 69 6e 7b 73 63 68 |ple,..\b|egin{sch|
|00003a30| 65 6d 65 7d 0a 28 61 20 | 62 20 63 20 64 20 65 29 |eme}.(a |b c d e)|
|00003a40| 25 0a 5c 65 6e 64 7b 73 | 63 68 65 6d 65 7d 0a 0a |%.\end{s|cheme}..|
|00003a50| 61 6e 64 0a 0a 5c 62 65 | 67 69 6e 7b 73 63 68 65 |and..\be|gin{sche|
|00003a60| 6d 65 7d 0a 28 61 20 2e | 20 28 62 20 2e 20 28 63 |me}.(a .| (b . (c|
|00003a70| 20 2e 20 28 64 20 2e 20 | 28 65 20 2e 20 28 29 29 | . (d . |(e . ())|
|00003a80| 29 29 29 29 25 0a 5c 65 | 6e 64 7b 73 63 68 65 6d |))))%.\e|nd{schem|
|00003a90| 65 7d 0a 0a 61 72 65 20 | 65 71 75 69 76 61 6c 65 |e}..are |equivale|
|00003aa0| 6e 74 20 6e 6f 74 61 74 | 69 6f 6e 73 20 66 6f 72 |nt notat|ions for|
|00003ab0| 20 61 20 6c 69 73 74 20 | 6f 66 20 73 79 6d 62 6f | a list |of symbo|
|00003ac0| 6c 73 2e 0a 0a 41 20 63 | 68 61 69 6e 20 6f 66 20 |ls...A c|hain of |
|00003ad0| 70 61 69 72 73 20 6e 6f | 74 20 65 6e 64 69 6e 67 |pairs no|t ending|
|00003ae0| 20 69 6e 20 74 68 65 20 | 65 6d 70 74 79 20 6c 69 | in the |empty li|
|00003af0| 73 74 20 69 73 20 63 61 | 6c 6c 65 64 20 61 6e 0a |st is ca|lled an.|
|00003b00| 5c 64 65 66 69 6e 69 6e | 67 7b 69 6d 70 72 6f 70 |\definin|g{improp|
|00003b10| 65 72 20 6c 69 73 74 7d | 2e 20 20 4e 6f 74 65 20 |er list}|. Note |
|00003b20| 74 68 61 74 20 61 6e 20 | 69 6d 70 72 6f 70 65 72 |that an |improper|
|00003b30| 20 6c 69 73 74 20 69 73 | 20 6e 6f 74 20 61 20 6c | list is| not a l|
|00003b40| 69 73 74 2e 0a 54 68 65 | 20 6c 69 73 74 20 61 6e |ist..The| list an|
|00003b50| 64 20 64 6f 74 74 65 64 | 20 6e 6f 74 61 74 69 6f |d dotted| notatio|
|00003b60| 6e 73 20 63 61 6e 20 62 | 65 20 63 6f 6d 62 69 6e |ns can b|e combin|
|00003b70| 65 64 20 74 6f 20 72 65 | 70 72 65 73 65 6e 74 0a |ed to re|present.|
|00003b80| 69 6d 70 72 6f 70 65 72 | 20 6c 69 73 74 73 3a 0a |improper| lists:.|
|00003b90| 0a 5c 62 65 67 69 6e 7b | 73 63 68 65 6d 65 7d 0a |.\begin{|scheme}.|
|00003ba0| 28 61 20 62 20 63 20 2e | 20 64 29 25 0a 5c 65 6e |(a b c .| d)%.\en|
|00003bb0| 64 7b 73 63 68 65 6d 65 | 7d 0a 0a 69 73 20 65 71 |d{scheme|}..is eq|
|00003bc0| 75 69 76 61 6c 65 6e 74 | 20 74 6f 0a 0a 5c 62 65 |uivalent| to..\be|
|00003bd0| 67 69 6e 7b 73 63 68 65 | 6d 65 7d 0a 28 61 20 2e |gin{sche|me}.(a .|
|00003be0| 20 28 62 20 2e 20 28 63 | 20 2e 20 64 29 29 29 25 | (b . (c| . d)))%|
|00003bf0| 0a 5c 65 6e 64 7b 73 63 | 68 65 6d 65 7d 0a 0a 57 |.\end{sc|heme}..W|
|00003c00| 68 65 74 68 65 72 20 61 | 20 67 69 76 65 6e 20 70 |hether a| given p|
|00003c10| 61 69 72 20 69 73 20 61 | 20 6c 69 73 74 20 64 65 |air is a| list de|
|00003c20| 70 65 6e 64 73 20 75 70 | 6f 6e 20 77 68 61 74 20 |pends up|on what |
|00003c30| 69 73 20 73 74 6f 72 65 | 64 20 69 6e 20 74 68 65 |is store|d in the|
|00003c40| 20 63 64 72 0a 66 69 65 | 6c 64 2e 20 20 57 68 65 | cdr.fie|ld. Whe|
|00003c50| 6e 20 74 68 65 20 5c 69 | 64 65 7b 73 65 74 2d 63 |n the \i|de{set-c|
|00003c60| 64 72 21 7d 20 70 72 6f | 63 65 64 75 72 65 20 69 |dr!} pro|cedure i|
|00003c70| 73 20 75 73 65 64 2c 20 | 61 6e 20 6f 62 6a 65 63 |s used, |an objec|
|00003c80| 74 20 63 61 6e 20 62 65 | 20 61 0a 6c 69 73 74 20 |t can be| a.list |
|00003c90| 6f 6e 65 20 6d 6f 6d 65 | 6e 74 20 61 6e 64 20 6e |one mome|nt and n|
|00003ca0| 6f 74 20 74 68 65 20 6e | 65 78 74 3a 0a 0a 5c 62 |ot the n|ext:..\b|
|00003cb0| 65 67 69 6e 7b 73 63 68 | 65 6d 65 7d 0a 28 64 65 |egin{sch|eme}.(de|
|00003cc0| 66 69 6e 65 20 78 20 28 | 6c 69 73 74 20 27 61 20 |fine x (|list 'a |
|00003cd0| 27 62 20 27 63 29 29 0a | 28 64 65 66 69 6e 65 20 |'b 'c)).|(define |
|00003ce0| 79 20 78 29 0a 79 20 20 | 20 20 20 20 20 20 20 20 |y x).y | |
|00003cf0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 5c 65 76 | | \ev|
|00003d00| 20 20 28 61 20 62 20 63 | 29 0a 28 6c 69 73 74 3f | (a b c|).(list?|
|00003d10| 20 79 29 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | y) | |
|00003d20| 20 20 5c 65 76 20 20 5c | 73 63 68 74 72 75 65 0a | \ev \|schtrue.|
|00003d30| 28 73 65 74 2d 63 64 72 | 21 20 78 20 34 29 20 20 |(set-cdr|! x 4) |
|00003d40| 20 20 20 20 20 20 20 20 | 5c 65 76 20 20 5c 75 6e | |\ev \un|
|00003d50| 73 70 65 63 69 66 69 65 | 64 0a 78 20 20 20 20 20 |specifie|d.x |
|00003d60| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00003d70| 20 20 5c 65 76 20 20 28 | 61 20 2e 20 34 29 0a 28 | \ev (|a . 4).(|
|00003d80| 65 71 76 3f 20 78 20 79 | 29 20 20 20 20 20 20 20 |eqv? x y|) |
|00003d90| 20 20 20 20 20 20 20 5c | 65 76 20 20 5c 73 63 68 | \|ev \sch|
|00003da0| 74 72 75 65 0a 79 20 20 | 20 20 20 20 20 20 20 20 |true.y | |
|00003db0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 5c 65 76 | | \ev|
|00003dc0| 20 20 28 61 20 2e 20 34 | 29 0a 28 6c 69 73 74 3f | (a . 4|).(list?|
|00003dd0| 20 79 29 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | y) | |
|00003de0| 20 20 5c 65 76 20 20 5c | 73 63 68 66 61 6c 73 65 | \ev \|schfalse|
|00003df0| 0a 28 73 65 74 2d 63 64 | 72 21 20 78 20 78 29 20 |.(set-cd|r! x x) |
|00003e00| 20 20 20 20 20 20 20 20 | 20 5c 65 76 20 20 5c 75 | | \ev \u|
|00003e10| 6e 73 70 65 63 69 66 69 | 65 64 0a 28 6c 69 73 74 |nspecifi|ed.(list|
|00003e20| 3f 20 78 29 20 20 20 20 | 20 20 20 20 20 20 20 20 |? x) | |
|00003e30| 20 20 20 5c 65 76 20 20 | 5c 73 63 68 66 61 6c 73 | \ev |\schfals|
|00003e40| 65 25 0a 5c 65 6e 64 7b | 73 63 68 65 6d 65 7d 0a |e%.\end{|scheme}.|
|00003e50| 0a 25 49 74 20 69 73 20 | 6f 66 74 65 6e 20 63 6f |.%It is |often co|
|00003e60| 6e 76 65 6e 69 65 6e 74 | 20 74 6f 20 73 70 65 61 |nvenient| to spea|
|00003e70| 6b 20 6f 66 20 61 20 68 | 6f 6d 6f 67 65 6e 65 6f |k of a h|omogeneo|
|00003e80| 75 73 20 6c 69 73 74 20 | 6f 66 20 6f 62 6a 65 63 |us list |of objec|
|00003e90| 74 73 0a 25 6f 66 20 73 | 6f 6d 65 20 70 61 72 74 |ts.%of s|ome part|
|00003ea0| 69 63 75 6c 61 72 20 64 | 61 74 61 20 74 79 70 65 |icular d|ata type|
|00003eb0| 2c 20 61 73 20 66 6f 72 | 20 65 78 61 6d 70 6c 65 |, as for| example|
|00003ec0| 20 5c 68 62 6f 78 7b 5c | 63 66 20 28 31 20 32 20 | \hbox{\|cf (1 2 |
|00003ed0| 33 29 7d 20 69 73 20 61 | 20 6c 69 73 74 20 6f 66 |3)} is a| list of|
|00003ee0| 0a 25 69 6e 74 65 67 65 | 72 73 2e 20 20 54 6f 20 |.%intege|rs. To |
|00003ef0| 62 65 20 6d 6f 72 65 20 | 70 72 65 63 69 73 65 2c |be more |precise,|
|00003f00| 20 73 75 70 70 6f 73 65 | 20 5c 76 61 72 7b 44 7d | suppose| \var{D}|
|00003f10| 20 69 73 20 73 6f 6d 65 | 20 64 61 74 61 20 74 79 | is some| data ty|
|00003f20| 70 65 2e 20 20 28 41 6e | 79 0a 25 70 72 65 64 69 |pe. (An|y.%predi|
|00003f30| 63 61 74 65 20 64 65 66 | 69 6e 65 73 20 61 20 64 |cate def|ines a d|
|00003f40| 61 74 61 20 74 79 70 65 | 20 63 6f 6e 73 69 73 74 |ata type| consist|
|00003f50| 69 6e 67 20 6f 66 20 74 | 68 6f 73 65 20 6f 62 6a |ing of t|hose obj|
|00003f60| 65 63 74 73 20 6f 66 20 | 77 68 69 63 68 20 74 68 |ects of |which th|
|00003f70| 65 0a 25 70 72 65 64 69 | 63 61 74 65 20 69 73 20 |e.%predi|cate is |
|00003f80| 74 72 75 65 2e 29 20 20 | 54 68 65 6e 0a 25 0a 25 |true.) |Then.%.%|
|00003f90| 5c 62 65 67 69 6e 7b 69 | 74 65 6d 69 7a 65 7d 0a |\begin{i|temize}.|
|00003fa0| 25 5c 69 74 65 6d 20 54 | 68 65 20 65 6d 70 74 79 |%\item T|he empty|
|00003fb0| 20 6c 69 73 74 20 69 73 | 20 61 20 6c 69 73 74 20 | list is| a list |
|00003fc0| 6f 66 20 5c 76 61 72 7b | 44 7d 2e 0a 25 5c 69 74 |of \var{|D}..%\it|
|00003fd0| 65 6d 20 49 66 20 5c 76 | 61 72 7b 6c 69 73 74 7d |em If \v|ar{list}|
|00003fe0| 20 69 73 20 61 20 6c 69 | 73 74 20 6f 66 20 5c 76 | is a li|st of \v|
|00003ff0| 61 72 7b 44 7d 2c 20 74 | 68 65 6e 20 61 6e 79 20 |ar{D}, t|hen any |
|00004000| 70 61 69 72 20 77 68 6f | 73 65 20 63 64 72 20 69 |pair who|se cdr i|
|00004010| 73 0a 25 20 20 20 20 20 | 20 5c 76 61 72 7b 6c 69 |s.% | \var{li|
|00004020| 73 74 7d 20 61 6e 64 20 | 77 68 6f 73 65 20 63 61 |st} and |whose ca|
|00004030| 72 20 69 73 20 61 6e 20 | 65 6c 65 6d 65 6e 74 20 |r is an |element |
|00004040| 6f 66 20 74 68 65 20 64 | 61 74 61 20 74 79 70 65 |of the d|ata type|
|00004050| 20 5c 76 61 72 7b 44 7d | 20 69 73 20 61 6c 73 6f | \var{D}| is also|
|00004060| 20 61 0a 25 20 20 20 20 | 20 20 6c 69 73 74 20 6f | a.% | list o|
|00004070| 66 20 5c 76 61 72 7b 44 | 7d 2e 0a 25 5c 69 74 65 |f \var{D|}..%\ite|
|00004080| 6d 20 54 68 65 72 65 20 | 61 72 65 20 6e 6f 20 6f |m There |are no o|
|00004090| 74 68 65 72 20 6c 69 73 | 74 73 20 6f 66 20 5c 76 |ther lis|ts of \v|
|000040a0| 61 72 7b 44 7d 2e 0a 25 | 5c 65 6e 64 7b 69 74 65 |ar{D}..%|\end{ite|
|000040b0| 6d 69 7a 65 7d 0a 0a 57 | 69 74 68 69 6e 20 6c 69 |mize}..W|ithin li|
|000040c0| 74 65 72 61 6c 20 65 78 | 70 72 65 73 73 69 6f 6e |teral ex|pression|
|000040d0| 73 20 61 6e 64 20 72 65 | 70 72 65 73 65 6e 74 61 |s and re|presenta|
|000040e0| 74 69 6f 6e 73 20 6f 66 | 20 6f 62 6a 65 63 74 73 |tions of| objects|
|000040f0| 20 72 65 61 64 20 62 79 | 20 74 68 65 0a 5c 69 64 | read by| the.\id|
|00004100| 65 7b 72 65 61 64 7d 20 | 70 72 6f 63 65 64 75 72 |e{read} |procedur|
|00004110| 65 2c 20 74 68 65 20 66 | 6f 72 6d 73 20 5c 73 69 |e, the f|orms \si|
|00004120| 6e 67 6c 65 71 75 6f 74 | 65 5c 68 79 70 65 72 7b |nglequot|e\hyper{|
|00004130| 64 61 74 75 6d 7d 5c 73 | 63 68 69 6e 64 65 78 7b |datum}\s|chindex{|
|00004140| 27 7d 2c 0a 5c 62 61 63 | 6b 71 75 6f 74 65 5c 68 |'},.\bac|kquote\h|
|00004150| 79 70 65 72 7b 64 61 74 | 75 6d 7d 2c 20 7b 5c 74 |yper{dat|um}, {\t|
|00004160| 74 2c 7d 5c 68 79 70 65 | 72 7b 64 61 74 75 6d 7d |t,}\hype|r{datum}|
|00004170| 5c 73 63 68 69 6e 64 65 | 78 7b 2c 7d 2c 20 61 6e |\schinde|x{,}, an|
|00004180| 64 0a 7b 5c 74 74 2c 40 | 7d 5c 68 79 70 65 72 7b |d.{\tt,@|}\hyper{|
|00004190| 64 61 74 75 6d 7d 20 64 | 65 6e 6f 74 65 20 74 77 |datum} d|enote tw|
|000041a0| 6f 2d 65 6c 65 5c 2d 6d | 65 6e 74 20 6c 69 73 74 |o-ele\-m|ent list|
|000041b0| 73 20 77 68 6f 73 65 20 | 66 69 72 73 74 20 65 6c |s whose |first el|
|000041c0| 65 6d 65 6e 74 73 20 61 | 72 65 0a 74 68 65 20 73 |ements a|re.the s|
|000041d0| 79 6d 62 6f 6c 73 20 5c | 69 64 65 7b 71 75 6f 74 |ymbols \|ide{quot|
|000041e0| 65 7d 2c 20 5c 69 64 65 | 7b 71 75 61 73 69 71 75 |e}, \ide|{quasiqu|
|000041f0| 6f 74 65 7d 2c 20 5c 68 | 62 6f 78 7b 5c 69 64 65 |ote}, \h|box{\ide|
|00004200| 7b 75 6e 71 75 6f 74 65 | 7d 7d 2c 20 61 6e 64 0a |{unquote|}}, and.|
|00004210| 5c 69 64 65 7b 75 6e 71 | 75 6f 74 65 2d 73 70 6c |\ide{unq|uote-spl|
|00004220| 69 63 69 6e 67 7d 2c 20 | 72 65 73 70 65 63 74 69 |icing}, |respecti|
|00004230| 76 65 6c 79 2e 20 20 54 | 68 65 20 73 65 63 6f 6e |vely. T|he secon|
|00004240| 64 20 65 6c 65 6d 65 6e | 74 20 69 6e 20 65 61 63 |d elemen|t in eac|
|00004250| 68 20 63 61 73 65 0a 69 | 73 20 5c 68 79 70 65 72 |h case.i|s \hyper|
|00004260| 7b 64 61 74 75 6d 7d 2e | 20 20 54 68 69 73 20 63 |{datum}.| This c|
|00004270| 6f 6e 76 65 6e 74 69 6f | 6e 20 69 73 20 73 75 70 |onventio|n is sup|
|00004280| 70 6f 72 74 65 64 20 73 | 6f 20 74 68 61 74 20 61 |ported s|o that a|
|00004290| 72 62 69 74 72 61 72 79 | 20 53 63 68 65 6d 65 0a |rbitrary| Scheme.|
|000042a0| 70 72 6f 67 72 61 6d 73 | 20 6d 61 79 20 62 65 20 |programs| may be |
|000042b0| 72 65 70 72 65 73 65 6e | 74 65 64 20 61 73 20 6c |represen|ted as l|
|000042c0| 69 73 74 73 2e 20 20 5c | 74 6f 64 6f 7b 43 61 6e |ists. \|todo{Can|
|000042d0| 20 6f 72 20 6e 65 65 64 | 20 74 68 69 73 20 62 65 | or need| this be|
|000042e0| 20 73 74 61 74 65 64 0a | 6d 6f 72 65 20 63 61 72 | stated.|more car|
|000042f0| 65 66 75 6c 6c 79 3f 7d | 20 54 68 61 74 20 69 73 |efully?}| That is|
|00004300| 2c 20 61 63 63 6f 72 64 | 69 6e 67 20 74 6f 20 53 |, accord|ing to S|
|00004310| 63 68 65 6d 65 27 73 20 | 67 72 61 6d 6d 61 72 2c |cheme's |grammar,|
|00004320| 20 65 76 65 72 79 0a 5c | 6d 65 74 61 7b 65 78 70 | every.\|meta{exp|
|00004330| 72 65 73 73 69 6f 6e 7d | 20 69 73 20 61 6c 73 6f |ression}| is also|
|00004340| 20 61 20 5c 6d 65 74 61 | 7b 64 61 74 75 6d 7d 20 | a \meta|{datum} |
|00004350| 28 73 65 65 20 73 65 63 | 74 69 6f 6e 7e 5c 72 65 |(see sec|tion~\re|
|00004360| 66 7b 64 61 74 75 6d 7d | 29 2e 0a 41 6d 6f 6e 67 |f{datum}|)..Among|
|00004370| 20 6f 74 68 65 72 20 74 | 68 69 6e 67 73 2c 20 74 | other t|hings, t|
|00004380| 68 69 73 20 70 65 72 6d | 69 74 73 20 74 68 65 20 |his perm|its the |
|00004390| 75 73 65 20 6f 66 20 74 | 68 65 20 5c 69 64 65 7b |use of t|he \ide{|
|000043a0| 72 65 61 64 7d 20 70 72 | 6f 63 65 64 75 72 65 20 |read} pr|ocedure |
|000043b0| 74 6f 0a 70 61 72 73 65 | 20 53 63 68 65 6d 65 20 |to.parse| Scheme |
|000043c0| 70 72 6f 67 72 61 6d 73 | 2e 20 20 53 65 65 20 73 |programs|. See s|
|000043d0| 65 63 74 69 6f 6e 7e 5c | 72 65 66 7b 65 78 74 65 |ection~\|ref{exte|
|000043e0| 72 6e 61 6c 72 65 70 73 | 7d 2e 20 0a 20 0a 0a 5c |rnalreps|}. . ..\|
|000043f0| 62 65 67 69 6e 7b 65 6e | 74 72 79 7d 7b 25 0a 5c |begin{en|try}{%.\|
|00004400| 70 72 6f 74 6f 7b 70 61 | 69 72 3f 7d 7b 20 6f 62 |proto{pa|ir?}{ ob|
|00004410| 6a 7d 7b 65 73 73 65 6e | 74 69 61 6c 20 70 72 6f |j}{essen|tial pro|
|00004420| 63 65 64 75 72 65 7d 7d | 0a 0a 5c 69 64 65 7b 50 |cedure}}|..\ide{P|
|00004430| 61 69 72 3f 7d 20 72 65 | 74 75 72 6e 73 20 5c 73 |air?} re|turns \s|
|00004440| 63 68 74 72 75 65 7b 7d | 20 69 66 20 5c 76 61 72 |chtrue{}| if \var|
|00004450| 7b 6f 62 6a 7d 20 69 73 | 20 61 20 70 61 69 72 2c |{obj} is| a pair,|
|00004460| 20 61 6e 64 20 6f 74 68 | 65 72 77 69 73 65 0a 72 | and oth|erwise.r|
|00004470| 65 74 75 72 6e 73 20 5c | 73 63 68 66 61 6c 73 65 |eturns \|schfalse|
|00004480| 2e 0a 0a 5c 62 65 67 69 | 6e 7b 73 63 68 65 6d 65 |...\begi|n{scheme|
|00004490| 7d 0a 28 70 61 69 72 3f | 20 27 28 61 20 2e 20 62 |}.(pair?| '(a . b|
|000044a0| 29 29 20 20 20 20 20 20 | 20 20 5c 65 76 20 20 5c |)) | \ev \|
|000044b0| 73 63 68 74 72 75 65 0a | 28 70 61 69 72 3f 20 27 |schtrue.|(pair? '|
|000044c0| 28 61 20 62 20 63 29 29 | 20 20 20 20 20 20 20 20 |(a b c))| |
|000044d0| 5c 65 76 20 20 5c 73 63 | 68 74 72 75 65 0a 28 70 |\ev \sc|htrue.(p|
|000044e0| 61 69 72 3f 20 27 28 29 | 29 20 20 20 20 20 20 20 |air? '()|) |
|000044f0| 20 20 20 20 20 20 5c 65 | 76 20 20 5c 73 63 68 66 | \e|v \schf|
|00004500| 61 6c 73 65 0a 28 70 61 | 69 72 3f 20 27 5c 23 28 |alse.(pa|ir? '\#(|
|00004510| 61 20 62 29 29 20 20 20 | 20 20 20 20 20 20 5c 65 |a b)) | \e|
|00004520| 76 20 20 5c 73 63 68 66 | 61 6c 73 65 25 0a 5c 65 |v \schf|alse%.\e|
|00004530| 6e 64 7b 73 63 68 65 6d | 65 7d 0a 5c 65 6e 64 7b |nd{schem|e}.\end{|
|00004540| 65 6e 74 72 79 7d 0a 0a | 0a 5c 62 65 67 69 6e 7b |entry}..|.\begin{|
|00004550| 65 6e 74 72 79 7d 7b 25 | 0a 5c 70 72 6f 74 6f 7b |entry}{%|.\proto{|
|00004560| 63 6f 6e 73 7d 7b 20 5c | 76 61 72 69 7b 6f 62 6a |cons}{ \|vari{obj|
|00004570| 7d 20 5c 76 61 72 69 69 | 7b 6f 62 6a 7d 7d 7b 65 |} \varii|{obj}}{e|
|00004580| 73 73 65 6e 74 69 61 6c | 20 70 72 6f 63 65 64 75 |ssential| procedu|
|00004590| 72 65 7d 7d 0a 0a 52 65 | 74 75 72 6e 73 20 61 20 |re}}..Re|turns a |
|000045a0| 6e 65 77 6c 79 20 61 6c | 6c 6f 63 61 74 65 64 20 |newly al|located |
|000045b0| 70 61 69 72 20 77 68 6f | 73 65 20 63 61 72 20 69 |pair who|se car i|
|000045c0| 73 20 5c 76 61 72 69 7b | 6f 62 6a 7d 20 61 6e 64 |s \vari{|obj} and|
|000045d0| 20 77 68 6f 73 65 20 63 | 64 72 20 69 73 0a 5c 76 | whose c|dr is.\v|
|000045e0| 61 72 69 69 7b 6f 62 6a | 7d 2e 20 20 54 68 65 20 |arii{obj|}. The |
|000045f0| 70 61 69 72 20 69 73 20 | 67 75 61 72 61 6e 74 65 |pair is |guarante|
|00004600| 65 64 20 74 6f 20 62 65 | 20 64 69 66 66 65 72 65 |ed to be| differe|
|00004610| 6e 74 20 28 69 6e 20 74 | 68 65 20 73 65 6e 73 65 |nt (in t|he sense|
|00004620| 20 6f 66 0a 5c 69 64 65 | 7b 65 71 76 3f 7d 29 20 | of.\ide|{eqv?}) |
|00004630| 66 72 6f 6d 20 65 76 65 | 72 79 20 65 78 69 73 74 |from eve|ry exist|
|00004640| 69 6e 67 20 6f 62 6a 65 | 63 74 2e 0a 0a 5c 62 65 |ing obje|ct...\be|
|00004650| 67 69 6e 7b 73 63 68 65 | 6d 65 7d 0a 28 63 6f 6e |gin{sche|me}.(con|
|00004660| 73 20 27 61 20 27 28 29 | 29 20 20 20 20 20 20 20 |s 'a '()|) |
|00004670| 20 20 20 20 5c 65 76 20 | 20 28 61 29 0a 28 63 6f | \ev | (a).(co|
|00004680| 6e 73 20 27 28 61 29 20 | 27 28 62 20 63 20 64 29 |ns '(a) |'(b c d)|
|00004690| 29 20 20 20 20 5c 65 76 | 20 20 28 28 61 29 20 62 |) \ev| ((a) b|
|000046a0| 20 63 20 64 29 0a 28 63 | 6f 6e 73 20 22 61 22 20 | c d).(c|ons "a" |
|000046b0| 27 28 62 20 63 29 29 20 | 20 20 20 20 20 20 5c 65 |'(b c)) | \e|
|000046c0| 76 20 20 28 22 61 22 20 | 62 20 63 29 0a 28 63 6f |v ("a" |b c).(co|
|000046d0| 6e 73 20 27 61 20 33 29 | 20 20 20 20 20 20 20 20 |ns 'a 3)| |
|000046e0| 20 20 20 20 20 5c 65 76 | 20 20 28 61 20 2e 20 33 | \ev| (a . 3|
|000046f0| 29 0a 28 63 6f 6e 73 20 | 27 28 61 20 62 29 20 27 |).(cons |'(a b) '|
|00004700| 63 29 20 20 20 20 20 20 | 20 20 5c 65 76 20 20 28 |c) | \ev (|
|00004710| 28 61 20 62 29 20 2e 20 | 63 29 25 0a 5c 65 6e 64 |(a b) . |c)%.\end|
|00004720| 7b 73 63 68 65 6d 65 7d | 0a 5c 65 6e 64 7b 65 6e |{scheme}|.\end{en|
|00004730| 74 72 79 7d 0a 0a 0a 5c | 62 65 67 69 6e 7b 65 6e |try}...\|begin{en|
|00004740| 74 72 79 7d 7b 25 0a 5c | 70 72 6f 74 6f 7b 63 61 |try}{%.\|proto{ca|
|00004750| 72 7d 7b 20 70 61 69 72 | 7d 7b 65 73 73 65 6e 74 |r}{ pair|}{essent|
|00004760| 69 61 6c 20 70 72 6f 63 | 65 64 75 72 65 7d 7d 0a |ial proc|edure}}.|
|00004770| 0a 5c 6e 6f 64 6f 6d 61 | 69 6e 7b 5c 76 61 72 7b |.\nodoma|in{\var{|
|00004780| 50 61 69 72 7d 20 6d 75 | 73 74 20 62 65 20 61 20 |Pair} mu|st be a |
|00004790| 70 61 69 72 2e 7d 0a 52 | 65 74 75 72 6e 73 20 74 |pair.}.R|eturns t|
|000047a0| 68 65 20 63 6f 6e 74 65 | 6e 74 73 20 6f 66 20 74 |he conte|nts of t|
|000047b0| 68 65 20 63 61 72 20 66 | 69 65 6c 64 20 6f 66 20 |he car f|ield of |
|000047c0| 5c 76 61 72 7b 70 61 69 | 72 7d 2e 20 20 4e 6f 74 |\var{pai|r}. Not|
|000047d0| 65 20 74 68 61 74 20 69 | 74 20 69 73 20 61 6e 0a |e that i|t is an.|
|000047e0| 65 72 72 6f 72 20 74 6f | 20 74 61 6b 65 20 74 68 |error to| take th|
|000047f0| 65 20 63 61 72 20 6f 66 | 20 74 68 65 20 65 6d 70 |e car of| the emp|
|00004800| 74 79 20 6c 69 73 74 5c | 69 6e 64 65 78 7b 65 6d |ty list\|index{em|
|00004810| 70 74 79 20 6c 69 73 74 | 7d 2e 0a 0a 5c 62 65 67 |pty list|}...\beg|
|00004820| 69 6e 7b 73 63 68 65 6d | 65 7d 0a 28 63 61 72 20 |in{schem|e}.(car |
|00004830| 27 28 61 20 62 20 63 29 | 29 20 20 20 20 20 20 20 |'(a b c)|) |
|00004840| 20 20 20 5c 65 76 20 20 | 61 0a 28 63 61 72 20 27 | \ev |a.(car '|
|00004850| 28 28 61 29 20 62 20 63 | 20 64 29 29 20 20 20 20 |((a) b c| d)) |
|00004860| 20 20 5c 65 76 20 20 28 | 61 29 0a 28 63 61 72 20 | \ev (|a).(car |
|00004870| 27 28 31 20 2e 20 32 29 | 29 20 20 20 20 20 20 20 |'(1 . 2)|) |
|00004880| 20 20 20 5c 65 76 20 20 | 31 0a 28 63 61 72 20 27 | \ev |1.(car '|
|00004890| 28 29 29 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |()) | |
|000048a0| 20 20 5c 65 76 20 20 5c | 73 63 68 65 72 72 6f 72 | \ev \|scherror|
|000048b0| 25 0a 5c 65 6e 64 7b 73 | 63 68 65 6d 65 7d 0a 20 |%.\end{s|cheme}. |
|000048c0| 0a 5c 65 6e 64 7b 65 6e | 74 72 79 7d 0a 0a 0a 5c |.\end{en|try}...\|
|000048d0| 62 65 67 69 6e 7b 65 6e | 74 72 79 7d 7b 25 0a 5c |begin{en|try}{%.\|
|000048e0| 70 72 6f 74 6f 7b 63 64 | 72 7d 7b 20 70 61 69 72 |proto{cd|r}{ pair|
|000048f0| 7d 7b 65 73 73 65 6e 74 | 69 61 6c 20 70 72 6f 63 |}{essent|ial proc|
|00004900| 65 64 75 72 65 7d 7d 0a | 0a 5c 6e 6f 64 6f 6d 61 |edure}}.|.\nodoma|
|00004910| 69 6e 7b 5c 76 61 72 7b | 50 61 69 72 7d 20 6d 75 |in{\var{|Pair} mu|
|00004920| 73 74 20 62 65 20 61 20 | 70 61 69 72 2e 7d 0a 52 |st be a |pair.}.R|
|00004930| 65 74 75 72 6e 73 20 74 | 68 65 20 63 6f 6e 74 65 |eturns t|he conte|
|00004940| 6e 74 73 20 6f 66 20 74 | 68 65 20 63 64 72 20 66 |nts of t|he cdr f|
|00004950| 69 65 6c 64 20 6f 66 20 | 5c 76 61 72 7b 70 61 69 |ield of |\var{pai|
|00004960| 72 7d 2e 0a 4e 6f 74 65 | 20 74 68 61 74 20 69 74 |r}..Note| that it|
|00004970| 20 69 73 20 61 6e 20 65 | 72 72 6f 72 20 74 6f 20 | is an e|rror to |
|00004980| 74 61 6b 65 20 74 68 65 | 20 63 64 72 20 6f 66 20 |take the| cdr of |
|00004990| 74 68 65 20 65 6d 70 74 | 79 20 6c 69 73 74 2e 0a |the empt|y list..|
|000049a0| 0a 5c 62 65 67 69 6e 7b | 73 63 68 65 6d 65 7d 0a |.\begin{|scheme}.|
|000049b0| 28 63 64 72 20 27 28 28 | 61 29 20 62 20 63 20 64 |(cdr '((|a) b c d|
|000049c0| 29 29 20 20 20 20 20 20 | 5c 65 76 20 20 28 62 20 |)) |\ev (b |
|000049d0| 63 20 64 29 0a 28 63 64 | 72 20 27 28 31 20 2e 20 |c d).(cd|r '(1 . |
|000049e0| 32 29 29 20 20 20 20 20 | 20 20 20 20 20 5c 65 76 |2)) | \ev|
|000049f0| 20 20 32 0a 28 63 64 72 | 20 27 28 29 29 20 20 20 | 2.(cdr| '()) |
|00004a00| 20 20 20 20 20 20 20 20 | 20 20 20 20 5c 65 76 20 | | \ev |
|00004a10| 20 5c 73 63 68 65 72 72 | 6f 72 25 0a 5c 65 6e 64 | \scherr|or%.\end|
|00004a20| 7b 73 63 68 65 6d 65 7d | 0a 20 0a 5c 65 6e 64 7b |{scheme}|. .\end{|
|00004a30| 65 6e 74 72 79 7d 0a 0a | 0a 5c 62 65 67 69 6e 7b |entry}..|.\begin{|
|00004a40| 65 6e 74 72 79 7d 7b 25 | 0a 5c 70 72 6f 74 6f 7b |entry}{%|.\proto{|
|00004a50| 73 65 74 2d 63 61 72 21 | 7d 7b 20 70 61 69 72 20 |set-car!|}{ pair |
|00004a60| 6f 62 6a 7d 7b 65 73 73 | 65 6e 74 69 61 6c 20 70 |obj}{ess|ential p|
|00004a70| 72 6f 63 65 64 75 72 65 | 7d 7d 0a 0a 5c 6e 6f 64 |rocedure|}}..\nod|
|00004a80| 6f 6d 61 69 6e 7b 5c 76 | 61 72 7b 50 61 69 72 7d |omain{\v|ar{Pair}|
|00004a90| 20 6d 75 73 74 20 62 65 | 20 61 20 70 61 69 72 2e | must be| a pair.|
|00004aa0| 7d 20 20 0a 53 74 6f 72 | 65 73 20 5c 76 61 72 7b |} .Stor|es \var{|
|00004ab0| 6f 62 6a 7d 20 69 6e 20 | 74 68 65 20 63 61 72 20 |obj} in |the car |
|00004ac0| 66 69 65 6c 64 20 6f 66 | 20 5c 76 61 72 7b 70 61 |field of| \var{pa|
|00004ad0| 69 72 7d 2e 0a 54 68 65 | 20 76 61 6c 75 65 20 72 |ir}..The| value r|
|00004ae0| 65 74 75 72 6e 65 64 20 | 62 79 20 5c 69 64 65 7b |eturned |by \ide{|
|00004af0| 73 65 74 2d 63 61 72 21 | 7d 5c 20 69 73 20 75 6e |set-car!|}\ is un|
|00004b00| 73 70 65 63 69 66 69 65 | 64 2e 20 20 25 20 3c 21 |specifie|d. % <!|
|00004b10| 3e 0a 25 54 68 69 73 20 | 70 72 6f 63 65 64 75 72 |>.%This |procedur|
|00004b20| 65 20 63 61 6e 20 62 65 | 20 76 65 72 79 20 63 6f |e can be| very co|
|00004b30| 6e 66 75 73 69 6e 67 20 | 69 66 20 75 73 65 64 20 |nfusing |if used |
|00004b40| 69 6e 64 69 73 63 72 69 | 6d 69 6e 61 74 65 6c 79 |indiscri|minately|
|00004b50| 2e 0a 0a 5c 62 65 67 69 | 6e 7b 73 63 68 65 6d 65 |...\begi|n{scheme|
|00004b60| 7d 0a 28 64 65 66 69 6e | 65 20 28 66 29 20 28 6c |}.(defin|e (f) (l|
|00004b70| 69 73 74 20 27 6e 6f 74 | 2d 61 2d 63 6f 6e 73 74 |ist 'not|-a-const|
|00004b80| 61 6e 74 2d 6c 69 73 74 | 29 29 0a 28 64 65 66 69 |ant-list|)).(defi|
|00004b90| 6e 65 20 28 67 29 20 27 | 28 63 6f 6e 73 74 61 6e |ne (g) '|(constan|
|00004ba0| 74 2d 6c 69 73 74 29 29 | 0a 28 73 65 74 2d 63 61 |t-list))|.(set-ca|
|00004bb0| 72 21 20 28 66 29 20 33 | 29 20 20 20 20 20 20 20 |r! (f) 3|) |
|00004bc0| 20 20 20 20 20 20 5c 65 | 76 20 20 5c 75 6e 73 70 | \e|v \unsp|
|00004bd0| 65 63 69 66 69 65 64 0a | 28 73 65 74 2d 63 61 72 |ecified.|(set-car|
|00004be0| 21 20 28 67 29 20 33 29 | 20 20 20 20 20 20 20 20 |! (g) 3)| |
|00004bf0| 20 20 20 20 20 5c 65 76 | 20 20 5c 73 63 68 65 72 | \ev| \scher|
|00004c00| 72 6f 72 25 0a 5c 65 6e | 64 7b 73 63 68 65 6d 65 |ror%.\en|d{scheme|
|00004c10| 7d 0a 0a 5c 65 6e 64 7b | 65 6e 74 72 79 7d 0a 0a |}..\end{|entry}..|
|00004c20| 0a 5c 62 65 67 69 6e 7b | 65 6e 74 72 79 7d 7b 25 |.\begin{|entry}{%|
|00004c30| 0a 5c 70 72 6f 74 6f 7b | 73 65 74 2d 63 64 72 21 |.\proto{|set-cdr!|
|00004c40| 7d 7b 20 70 61 69 72 20 | 6f 62 6a 7d 7b 65 73 73 |}{ pair |obj}{ess|
|00004c50| 65 6e 74 69 61 6c 20 70 | 72 6f 63 65 64 75 72 65 |ential p|rocedure|
|00004c60| 7d 7d 0a 0a 5c 6e 6f 64 | 6f 6d 61 69 6e 7b 5c 76 |}}..\nod|omain{\v|
|00004c70| 61 72 7b 50 61 69 72 7d | 20 6d 75 73 74 20 62 65 |ar{Pair}| must be|
|00004c80| 20 61 20 70 61 69 72 2e | 7d 0a 53 74 6f 72 65 73 | a pair.|}.Stores|
|00004c90| 20 5c 76 61 72 7b 6f 62 | 6a 7d 20 69 6e 20 74 68 | \var{ob|j} in th|
|00004ca0| 65 20 63 64 72 20 66 69 | 65 6c 64 20 6f 66 20 5c |e cdr fi|eld of \|
|00004cb0| 76 61 72 7b 70 61 69 72 | 7d 2e 0a 54 68 65 20 76 |var{pair|}..The v|
|00004cc0| 61 6c 75 65 20 72 65 74 | 75 72 6e 65 64 20 62 79 |alue ret|urned by|
|00004cd0| 20 5c 69 64 65 7b 73 65 | 74 2d 63 64 72 21 7d 5c | \ide{se|t-cdr!}\|
|00004ce0| 20 69 73 20 75 6e 73 70 | 65 63 69 66 69 65 64 2e | is unsp|ecified.|
|00004cf0| 20 20 25 20 3c 21 3e 0a | 25 54 68 69 73 20 70 72 | % <!>.|%This pr|
|00004d00| 6f 63 65 64 75 72 65 20 | 63 61 6e 20 62 65 20 76 |ocedure |can be v|
|00004d10| 65 72 79 20 63 6f 6e 66 | 75 73 69 6e 67 20 69 66 |ery conf|using if|
|00004d20| 20 75 73 65 64 20 69 6e | 64 69 73 63 72 69 6d 69 | used in|discrimi|
|00004d30| 6e 61 74 65 6c 79 2e 0a | 0a 5c 65 6e 64 7b 65 6e |nately..|.\end{en|
|00004d40| 74 72 79 7d 0a 0a 5c 73 | 65 74 62 6f 78 30 5c 68 |try}..\s|etbox0\h|
|00004d50| 62 6f 78 7b 5c 74 74 28 | 63 61 64 72 20 5c 76 61 |box{\tt(|cadr \va|
|00004d60| 72 7b 70 61 69 72 7d 29 | 7d 0a 5c 73 65 74 62 6f |r{pair})|}.\setbo|
|00004d70| 78 31 5c 68 62 6f 78 7b | 65 73 73 65 6e 74 69 61 |x1\hbox{|essentia|
|00004d80| 6c 20 70 72 6f 63 65 64 | 75 72 65 7d 0a 0a 0a 5c |l proced|ure}...\|
|00004d90| 62 65 67 69 6e 7b 65 6e | 74 72 79 7d 7b 25 0a 5c |begin{en|try}{%.\|
|00004da0| 70 72 6f 74 6f 7b 63 61 | 61 72 7d 7b 20 70 61 69 |proto{ca|ar}{ pai|
|00004db0| 72 7d 7b 65 73 73 65 6e | 74 69 61 6c 20 70 72 6f |r}{essen|tial pro|
|00004dc0| 63 65 64 75 72 65 7d 0a | 5c 70 72 6f 74 6f 7b 63 |cedure}.|\proto{c|
|00004dd0| 61 64 72 7d 7b 20 70 61 | 69 72 7d 7b 65 73 73 65 |adr}{ pa|ir}{esse|
|00004de0| 6e 74 69 61 6c 20 70 72 | 6f 63 65 64 75 72 65 7d |ntial pr|ocedure}|
|00004df0| 0a 5c 70 70 72 6f 74 6f | 7b 5c 68 62 6f 78 20 74 |.\pproto|{\hbox t|
|00004e00| 6f 20 31 5c 77 64 30 20 | 7b 5c 68 66 69 6c 24 5c |o 1\wd0 |{\hfil$\|
|00004e10| 76 64 6f 74 73 24 5c 68 | 66 69 6c 7d 7d 7b 5c 68 |vdots$\h|fil}}{\h|
|00004e20| 62 6f 78 20 74 6f 20 31 | 5c 77 64 31 20 7b 5c 68 |box to 1|\wd1 {\h|
|00004e30| 66 69 6c 24 5c 76 64 6f | 74 73 24 5c 68 66 69 6c |fil$\vdo|ts$\hfil|
|00004e40| 7d 7d 0a 5c 70 72 6f 74 | 6f 7b 63 64 64 64 61 72 |}}.\prot|o{cdddar|
|00004e50| 7d 7b 20 70 61 69 72 7d | 7b 65 73 73 65 6e 74 69 |}{ pair}|{essenti|
|00004e60| 61 6c 20 70 72 6f 63 65 | 64 75 72 65 7d 0a 5c 70 |al proce|dure}.\p|
|00004e70| 72 6f 74 6f 7b 63 64 64 | 64 64 72 7d 7b 20 70 61 |roto{cdd|ddr}{ pa|
|00004e80| 69 72 7d 7b 65 73 73 65 | 6e 74 69 61 6c 20 70 72 |ir}{esse|ntial pr|
|00004e90| 6f 63 65 64 75 72 65 7d | 7d 0a 0a 54 68 65 73 65 |ocedure}|}..These|
|00004ea0| 20 70 72 6f 63 65 64 75 | 72 65 73 20 61 72 65 20 | procedu|res are |
|00004eb0| 63 6f 6d 70 6f 73 69 74 | 69 6f 6e 73 20 6f 66 20 |composit|ions of |
|00004ec0| 5c 69 64 65 7b 63 61 72 | 7d 20 61 6e 64 20 5c 69 |\ide{car|} and \i|
|00004ed0| 64 65 7b 63 64 72 7d 2c | 20 77 68 65 72 65 0a 66 |de{cdr},| where.f|
|00004ee0| 6f 72 20 65 78 61 6d 70 | 6c 65 20 5c 69 64 65 7b |or examp|le \ide{|
|00004ef0| 63 61 64 64 72 7d 20 63 | 6f 75 6c 64 20 62 65 20 |caddr} c|ould be |
|00004f00| 64 65 66 69 6e 65 64 20 | 62 79 0a 0a 5c 62 65 67 |defined |by..\beg|
|00004f10| 69 6e 7b 73 63 68 65 6d | 65 7d 0a 28 64 65 66 69 |in{schem|e}.(defi|
|00004f20| 6e 65 20 63 61 64 64 72 | 20 28 6c 61 6d 62 64 61 |ne caddr| (lambda|
|00004f30| 20 28 78 29 20 28 63 61 | 72 20 28 63 64 72 20 28 | (x) (ca|r (cdr (|
|00004f40| 63 64 72 20 78 29 29 29 | 29 29 7b 5c 72 6d 2e 7d |cdr x)))|)){\rm.}|
|00004f50| 25 0a 5c 65 6e 64 7b 73 | 63 68 65 6d 65 7d 0a 0a |%.\end{s|cheme}..|
|00004f60| 41 72 62 69 74 72 61 72 | 79 20 63 6f 6d 70 6f 73 |Arbitrar|y compos|
|00004f70| 69 74 69 6f 6e 73 2c 20 | 75 70 20 74 6f 20 66 6f |itions, |up to fo|
|00004f80| 75 72 20 64 65 65 70 2c | 20 61 72 65 20 70 72 6f |ur deep,| are pro|
|00004f90| 76 69 64 65 64 2e 20 20 | 54 68 65 72 65 20 61 72 |vided. |There ar|
|00004fa0| 65 0a 74 77 65 6e 74 79 | 2d 65 69 67 68 74 20 6f |e.twenty|-eight o|
|00004fb0| 66 20 74 68 65 73 65 20 | 70 72 6f 63 65 64 75 72 |f these |procedur|
|00004fc0| 65 73 20 69 6e 20 61 6c | 6c 2e 0a 0a 5c 65 6e 64 |es in al|l...\end|
|00004fd0| 7b 65 6e 74 72 79 7d 0a | 0a 0a 5c 62 65 67 69 6e |{entry}.|..\begin|
|00004fe0| 7b 65 6e 74 72 79 7d 7b | 25 0a 5c 70 72 6f 74 6f |{entry}{|%.\proto|
|00004ff0| 7b 6e 75 6c 6c 3f 7d 7b | 20 6f 62 6a 7d 7b 65 73 |{null?}{| obj}{es|
|00005000| 73 65 6e 74 69 61 6c 20 | 70 72 6f 63 65 64 75 72 |sential |procedur|
|00005010| 65 7d 7d 0a 0a 52 65 74 | 75 72 6e 73 20 5c 73 63 |e}}..Ret|urns \sc|
|00005020| 68 74 72 75 65 7b 7d 20 | 69 66 20 5c 76 61 72 7b |htrue{} |if \var{|
|00005030| 6f 62 6a 7d 20 69 73 20 | 74 68 65 20 65 6d 70 74 |obj} is |the empt|
|00005040| 79 20 6c 69 73 74 5c 69 | 6e 64 65 78 7b 65 6d 70 |y list\i|ndex{emp|
|00005050| 74 79 20 6c 69 73 74 7d | 2c 0a 6f 74 68 65 72 77 |ty list}|,.otherw|
|00005060| 69 73 65 20 72 65 74 75 | 72 6e 73 20 5c 73 63 68 |ise retu|rns \sch|
|00005070| 66 61 6c 73 65 2e 0a 0a | 25 20 5c 62 65 67 69 6e |false...|% \begin|
|00005080| 7b 6e 6f 74 65 7d 0a 25 | 20 49 6e 20 69 6d 70 6c |{note}.%| In impl|
|00005090| 65 6d 65 6e 74 61 74 69 | 6f 6e 73 20 69 6e 20 77 |ementati|ons in w|
|000050a0| 68 69 63 68 20 74 68 65 | 20 65 6d 70 74 79 0a 25 |hich the| empty.%|
|000050b0| 20 6c 69 73 74 20 69 73 | 20 74 68 65 20 73 61 6d | list is| the sam|
|000050c0| 65 20 61 73 20 5c 73 63 | 68 66 61 6c 73 65 7b 7d |e as \sc|hfalse{}|
|000050d0| 2c 20 5c 69 64 65 7b 6e | 75 6c 6c 3f 7d 20 77 69 |, \ide{n|ull?} wi|
|000050e0| 6c 6c 20 72 65 74 75 72 | 6e 20 5c 73 63 68 74 72 |ll retur|n \schtr|
|000050f0| 75 65 7b 7d 0a 25 20 69 | 66 20 5c 76 61 72 7b 6f |ue{}.% i|f \var{o|
|00005100| 62 6a 7d 20 69 73 20 5c | 73 63 68 66 61 6c 73 65 |bj} is \|schfalse|
|00005110| 7b 7d 2e 0a 25 20 5c 65 | 6e 64 7b 6e 6f 74 65 7d |{}..% \e|nd{note}|
|00005120| 0a 20 0a 5c 65 6e 64 7b | 65 6e 74 72 79 7d 0a 0a |. .\end{|entry}..|
|00005130| 5c 62 65 67 69 6e 7b 65 | 6e 74 72 79 7d 7b 25 0a |\begin{e|ntry}{%.|
|00005140| 5c 70 72 6f 74 6f 7b 6c | 69 73 74 3f 7d 7b 20 6f |\proto{l|ist?}{ o|
|00005150| 62 6a 7d 7b 65 73 73 65 | 6e 74 69 61 6c 20 70 72 |bj}{esse|ntial pr|
|00005160| 6f 63 65 64 75 72 65 7d | 7d 0a 0a 52 65 74 75 72 |ocedure}|}..Retur|
|00005170| 6e 73 20 5c 73 63 68 74 | 72 75 65 7b 7d 20 69 66 |ns \scht|rue{} if|
|00005180| 20 5c 76 61 72 7b 6f 62 | 6a 7d 20 69 73 20 61 20 | \var{ob|j} is a |
|00005190| 6c 69 73 74 2c 20 6f 74 | 68 65 72 77 69 73 65 20 |list, ot|herwise |
|000051a0| 72 65 74 75 72 6e 73 20 | 5c 73 63 68 66 61 6c 73 |returns |\schfals|
|000051b0| 65 7b 7d 2e 0a 42 79 20 | 64 65 66 69 6e 69 74 69 |e{}..By |definiti|
|000051c0| 6f 6e 2c 20 61 6c 6c 20 | 6c 69 73 74 73 20 68 61 |on, all |lists ha|
|000051d0| 76 65 20 66 69 6e 69 74 | 65 20 6c 65 6e 67 74 68 |ve finit|e length|
|000051e0| 20 61 6e 64 20 61 72 65 | 20 74 65 72 6d 69 6e 61 | and are| termina|
|000051f0| 74 65 64 20 62 79 0a 74 | 68 65 20 65 6d 70 74 79 |ted by.t|he empty|
|00005200| 20 6c 69 73 74 2e 0a 0a | 5c 62 65 67 69 6e 7b 73 | list...|\begin{s|
|00005210| 63 68 65 6d 65 7d 0a 20 | 20 20 20 20 20 20 20 28 |cheme}. | (|
|00005220| 6c 69 73 74 3f 20 27 28 | 61 20 62 20 63 29 29 20 |list? '(|a b c)) |
|00005230| 20 20 20 20 5c 65 76 20 | 20 5c 73 63 68 74 72 75 | \ev | \schtru|
|00005240| 65 0a 20 20 20 20 20 20 | 20 20 28 6c 69 73 74 3f |e. | (list?|
|00005250| 20 27 28 29 29 20 20 20 | 20 20 20 20 20 20 20 5c | '()) | \|
|00005260| 65 76 20 20 5c 73 63 68 | 74 72 75 65 0a 20 20 20 |ev \sch|true. |
|00005270| 20 20 20 20 20 28 6c 69 | 73 74 3f 20 27 28 61 20 | (li|st? '(a |
|00005280| 2e 20 62 29 29 20 20 20 | 20 20 5c 65 76 20 20 5c |. b)) | \ev \|
|00005290| 73 63 68 66 61 6c 73 65 | 0a 20 20 20 20 20 20 20 |schfalse|. |
|000052a0| 20 28 6c 65 74 20 28 28 | 78 20 28 6c 69 73 74 20 | (let ((|x (list |
|000052b0| 27 61 29 29 29 0a 20 20 | 20 20 20 20 20 20 20 20 |'a))). | |
|000052c0| 28 73 65 74 2d 63 64 72 | 21 20 78 20 78 29 0a 20 |(set-cdr|! x x). |
|000052d0| 20 20 20 20 20 20 20 20 | 20 28 6c 69 73 74 3f 20 | | (list? |
|000052e0| 78 29 29 20 20 20 20 20 | 20 20 20 20 5c 65 76 20 |x)) | \ev |
|000052f0| 20 5c 73 63 68 66 61 6c | 73 65 25 0a 5c 65 6e 64 | \schfal|se%.\end|
|00005300| 7b 73 63 68 65 6d 65 7d | 0a 5c 65 6e 64 7b 65 6e |{scheme}|.\end{en|
|00005310| 74 72 79 7d 0a 0a 0a 5c | 62 65 67 69 6e 7b 65 6e |try}...\|begin{en|
|00005320| 74 72 79 7d 7b 25 0a 5c | 70 72 6f 74 6f 7b 6c 69 |try}{%.\|proto{li|
|00005330| 73 74 7d 7b 20 5c 76 61 | 72 7b 6f 62 6a 7d 20 5c |st}{ \va|r{obj} \|
|00005340| 64 6f 74 73 66 6f 6f 7d | 7b 65 73 73 65 6e 74 69 |dotsfoo}|{essenti|
|00005350| 61 6c 20 70 72 6f 63 65 | 64 75 72 65 7d 7d 0a 0a |al proce|dure}}..|
|00005360| 52 65 74 75 72 6e 73 20 | 61 20 6e 65 77 6c 79 20 |Returns |a newly |
|00005370| 61 6c 6c 6f 63 61 74 65 | 64 20 6c 69 73 74 20 6f |allocate|d list o|
|00005380| 66 20 69 74 73 20 61 72 | 67 75 6d 65 6e 74 73 2e |f its ar|guments.|
|00005390| 0a 0a 5c 62 65 67 69 6e | 7b 73 63 68 65 6d 65 7d |..\begin|{scheme}|
|000053a0| 0a 28 6c 69 73 74 20 27 | 61 20 28 2b 20 33 20 34 |.(list '|a (+ 3 4|
|000053b0| 29 20 27 63 29 20 20 20 | 20 20 20 20 20 20 20 20 |) 'c) | |
|000053c0| 20 5c 65 76 20 20 28 61 | 20 37 20 63 29 0a 28 6c | \ev (a| 7 c).(l|
|000053d0| 69 73 74 29 20 20 20 20 | 20 20 20 20 20 20 20 20 |ist) | |
|000053e0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 5c 65 | | \e|
|000053f0| 76 20 20 28 29 25 0a 5c | 65 6e 64 7b 73 63 68 65 |v ()%.\|end{sche|
|00005400| 6d 65 7d 0a 5c 65 6e 64 | 7b 65 6e 74 72 79 7d 0a |me}.\end|{entry}.|
|00005410| 0a 0a 5c 62 65 67 69 6e | 7b 65 6e 74 72 79 7d 7b |..\begin|{entry}{|
|00005420| 25 0a 5c 70 72 6f 74 6f | 7b 6c 65 6e 67 74 68 7d |%.\proto|{length}|
|00005430| 7b 20 6c 69 73 74 7d 7b | 65 73 73 65 6e 74 69 61 |{ list}{|essentia|
|00005440| 6c 20 70 72 6f 63 65 64 | 75 72 65 7d 7d 0a 0a 5c |l proced|ure}}..\|
|00005450| 6e 6f 64 6f 6d 61 69 6e | 7b 5c 76 61 72 7b 4c 69 |nodomain|{\var{Li|
|00005460| 73 74 7d 20 6d 75 73 74 | 20 62 65 20 61 20 6c 69 |st} must| be a li|
|00005470| 73 74 2e 7d 0a 52 65 74 | 75 72 6e 73 20 74 68 65 |st.}.Ret|urns the|
|00005480| 20 6c 65 6e 67 74 68 20 | 6f 66 20 5c 76 61 72 7b | length |of \var{|
|00005490| 6c 69 73 74 7d 2e 0a 0a | 5c 62 65 67 69 6e 7b 73 |list}...|\begin{s|
|000054a0| 63 68 65 6d 65 7d 0a 28 | 6c 65 6e 67 74 68 20 27 |cheme}.(|length '|
|000054b0| 28 61 20 62 20 63 29 29 | 20 20 20 20 20 20 20 20 |(a b c))| |
|000054c0| 20 20 20 20 20 20 20 5c | 65 76 20 20 33 0a 28 6c | \|ev 3.(l|
|000054d0| 65 6e 67 74 68 20 27 28 | 61 20 28 62 29 20 28 63 |ength '(|a (b) (c|
|000054e0| 20 64 20 65 29 29 29 20 | 20 20 20 20 20 20 5c 65 | d e))) | \e|
|000054f0| 76 20 20 33 0a 28 6c 65 | 6e 67 74 68 20 27 28 29 |v 3.(le|ngth '()|
|00005500| 29 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |) | |
|00005510| 20 20 20 20 20 5c 65 76 | 20 20 30 25 0a 5c 65 6e | \ev| 0%.\en|
|00005520| 64 7b 73 63 68 65 6d 65 | 7d 0a 5c 65 6e 64 7b 65 |d{scheme|}.\end{e|
|00005530| 6e 74 72 79 7d 0a 0a 0a | 5c 62 65 67 69 6e 7b 65 |ntry}...|\begin{e|
|00005540| 6e 74 72 79 7d 7b 25 0a | 5c 70 72 6f 74 6f 7b 61 |ntry}{%.|\proto{a|
|00005550| 70 70 65 6e 64 7d 7b 20 | 6c 69 73 74 20 5c 64 6f |ppend}{ |list \do|
|00005560| 74 73 66 6f 6f 7d 7b 65 | 73 73 65 6e 74 69 61 6c |tsfoo}{e|ssential|
|00005570| 20 70 72 6f 63 65 64 75 | 72 65 7d 7d 0a 0a 5c 6e | procedu|re}}..\n|
|00005580| 6f 64 6f 6d 61 69 6e 7b | 41 6c 6c 20 5c 76 61 72 |odomain{|All \var|
|00005590| 7b 6c 69 73 74 7d 73 20 | 73 68 6f 75 6c 64 20 62 |{list}s |should b|
|000055a0| 65 20 6c 69 73 74 73 2e | 7d 0a 52 65 74 75 72 6e |e lists.|}.Return|
|000055b0| 73 20 61 20 6c 69 73 74 | 20 63 6f 6e 73 69 73 74 |s a list| consist|
|000055c0| 69 6e 67 20 6f 66 20 74 | 68 65 20 65 6c 65 6d 65 |ing of t|he eleme|
|000055d0| 6e 74 73 20 6f 66 20 74 | 68 65 20 66 69 72 73 74 |nts of t|he first|
|000055e0| 20 5c 76 61 72 7b 6c 69 | 73 74 7d 0a 66 6f 6c 6c | \var{li|st}.foll|
|000055f0| 6f 77 65 64 20 62 79 20 | 74 68 65 20 65 6c 65 6d |owed by |the elem|
|00005600| 65 6e 74 73 20 6f 66 20 | 74 68 65 20 6f 74 68 65 |ents of |the othe|
|00005610| 72 20 5c 76 61 72 7b 6c | 69 73 74 7d 73 2e 0a 0a |r \var{l|ist}s...|
|00005620| 5c 62 65 67 69 6e 7b 73 | 63 68 65 6d 65 7d 0a 28 |\begin{s|cheme}.(|
|00005630| 61 70 70 65 6e 64 20 27 | 28 78 29 20 27 28 79 29 |append '|(x) '(y)|
|00005640| 29 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 5c |) | \|
|00005650| 65 76 20 20 28 78 20 79 | 29 0a 28 61 70 70 65 6e |ev (x y|).(appen|
|00005660| 64 20 27 28 61 29 20 27 | 28 62 20 63 20 64 29 29 |d '(a) '|(b c d))|
|00005670| 20 20 20 20 20 20 20 20 | 20 20 5c 65 76 20 20 28 | | \ev (|
|00005680| 61 20 62 20 63 20 64 29 | 0a 28 61 70 70 65 6e 64 |a b c d)|.(append|
|00005690| 20 27 28 61 20 28 62 29 | 29 20 27 28 28 63 29 29 | '(a (b)|) '((c))|
|000056a0| 29 20 20 20 20 20 20 20 | 20 5c 65 76 20 20 28 61 |) | \ev (a|
|000056b0| 20 28 62 29 20 28 63 29 | 29 25 0a 5c 65 6e 64 7b | (b) (c)|)%.\end{|
|000056c0| 73 63 68 65 6d 65 7d 0a | 0a 54 68 65 20 72 65 73 |scheme}.|.The res|
|000056d0| 75 6c 74 69 6e 67 20 6c | 69 73 74 20 69 73 20 61 |ulting l|ist is a|
|000056e0| 6c 77 61 79 73 20 6e 65 | 77 6c 79 20 61 6c 6c 6f |lways ne|wly allo|
|000056f0| 63 61 74 65 64 2c 20 65 | 78 63 65 70 74 20 74 68 |cated, e|xcept th|
|00005700| 61 74 20 69 74 20 73 68 | 61 72 65 73 0a 73 74 72 |at it sh|ares.str|
|00005710| 75 63 74 75 72 65 20 77 | 69 74 68 20 74 68 65 20 |ucture w|ith the |
|00005720| 6c 61 73 74 20 5c 76 61 | 72 7b 6c 69 73 74 7d 20 |last \va|r{list} |
|00005730| 61 72 67 75 6d 65 6e 74 | 2e 20 20 54 68 65 20 6c |argument|. The l|
|00005740| 61 73 74 20 61 72 67 75 | 6d 65 6e 74 20 6d 61 79 |ast argu|ment may|
|00005750| 0a 61 63 74 75 61 6c 6c | 79 20 62 65 20 61 6e 79 |.actuall|y be any|
|00005760| 20 6f 62 6a 65 63 74 3b | 20 61 6e 20 69 6d 70 72 | object;| an impr|
|00005770| 6f 70 65 72 20 6c 69 73 | 74 20 72 65 73 75 6c 74 |oper lis|t result|
|00005780| 73 20 69 66 20 74 68 65 | 20 6c 61 73 74 20 61 72 |s if the| last ar|
|00005790| 67 75 6d 65 6e 74 20 69 | 73 20 6e 6f 74 20 61 0a |gument i|s not a.|
|000057a0| 70 72 6f 70 65 72 20 6c | 69 73 74 2e 20 20 5c 74 |proper l|ist. \t|
|000057b0| 6f 64 6f 7b 54 68 69 73 | 20 69 73 20 70 72 65 74 |odo{This| is pret|
|000057c0| 74 79 20 61 77 6b 77 61 | 72 64 2e 20 20 49 20 73 |ty awkwa|rd. I s|
|000057d0| 68 6f 75 6c 64 20 67 65 | 74 20 42 61 72 74 6c 65 |hould ge|t Bartle|
|000057e0| 79 20 74 6f 20 66 69 78 | 20 74 68 69 73 2e 7d 0a |y to fix| this.}.|
|000057f0| 0a 5c 62 65 67 69 6e 7b | 73 63 68 65 6d 65 7d 0a |.\begin{|scheme}.|
|00005800| 28 61 70 70 65 6e 64 20 | 27 28 61 20 62 29 20 27 |(append |'(a b) '|
|00005810| 28 63 20 2e 20 64 29 29 | 20 20 20 20 20 20 20 20 |(c . d))| |
|00005820| 5c 65 76 20 20 28 61 20 | 62 20 63 20 2e 20 64 29 |\ev (a |b c . d)|
|00005830| 0a 28 61 70 70 65 6e 64 | 20 27 28 29 20 27 61 29 |.(append| '() 'a)|
|00005840| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00005850| 20 5c 65 76 20 20 61 25 | 0a 5c 65 6e 64 7b 73 63 | \ev a%|.\end{sc|
|00005860| 68 65 6d 65 7d 0a 5c 65 | 6e 64 7b 65 6e 74 72 79 |heme}.\e|nd{entry|
|00005870| 7d 0a 0a 0a 5c 62 65 67 | 69 6e 7b 65 6e 74 72 79 |}...\beg|in{entry|
|00005880| 7d 7b 25 0a 5c 70 72 6f | 74 6f 7b 72 65 76 65 72 |}{%.\pro|to{rever|
|00005890| 73 65 7d 7b 20 6c 69 73 | 74 7d 7b 65 73 73 65 6e |se}{ lis|t}{essen|
|000058a0| 74 69 61 6c 20 70 72 6f | 63 65 64 75 72 65 7d 7d |tial pro|cedure}}|
|000058b0| 0a 0a 5c 6e 6f 64 6f 6d | 61 69 6e 7b 5c 76 61 72 |..\nodom|ain{\var|
|000058c0| 7b 4c 69 73 74 7d 20 6d | 75 73 74 20 62 65 20 61 |{List} m|ust be a|
|000058d0| 20 6c 69 73 74 2e 7d 0a | 52 65 74 75 72 6e 73 20 | list.}.|Returns |
|000058e0| 61 20 6e 65 77 6c 79 20 | 61 6c 6c 6f 63 61 74 65 |a newly |allocate|
|000058f0| 64 20 6c 69 73 74 20 63 | 6f 6e 73 69 73 74 69 6e |d list c|onsistin|
|00005900| 67 20 6f 66 20 74 68 65 | 20 65 6c 65 6d 65 6e 74 |g of the| element|
|00005910| 73 20 6f 66 20 5c 76 61 | 72 7b 6c 69 73 74 7d 0a |s of \va|r{list}.|
|00005920| 69 6e 20 72 65 76 65 72 | 73 65 20 6f 72 64 65 72 |in rever|se order|
|00005930| 2e 0a 0a 5c 62 65 67 69 | 6e 7b 73 63 68 65 6d 65 |...\begi|n{scheme|
|00005940| 7d 0a 28 72 65 76 65 72 | 73 65 20 27 28 61 20 62 |}.(rever|se '(a b|
|00005950| 20 63 29 29 20 20 20 20 | 20 20 20 20 20 20 20 20 | c)) | |
|00005960| 20 20 5c 65 76 20 20 28 | 63 20 62 20 61 29 0a 28 | \ev (|c b a).(|
|00005970| 72 65 76 65 72 73 65 20 | 27 28 61 20 28 62 20 63 |reverse |'(a (b c|
|00005980| 29 20 64 20 28 65 20 28 | 66 29 29 29 29 20 20 5c |) d (e (|f)))) \|
|00005990| 6c 65 76 20 20 28 28 65 | 20 28 66 29 29 20 64 20 |lev ((e| (f)) d |
|000059a0| 28 62 20 63 29 20 61 29 | 25 0a 5c 65 6e 64 7b 73 |(b c) a)|%.\end{s|
|000059b0| 63 68 65 6d 65 7d 0a 5c | 65 6e 64 7b 65 6e 74 72 |cheme}.\|end{entr|
|000059c0| 79 7d 0a 0a 0a 5c 62 65 | 67 69 6e 7b 65 6e 74 72 |y}...\be|gin{entr|
|000059d0| 79 7d 7b 25 0a 5c 70 72 | 6f 74 6f 7b 6c 69 73 74 |y}{%.\pr|oto{list|
|000059e0| 2d 74 61 69 6c 7d 7b 20 | 6c 69 73 74 20 5c 76 72 |-tail}{ |list \vr|
|000059f0| 7b 6b 7d 7d 7b 70 72 6f | 63 65 64 75 72 65 7d 7d |{k}}{pro|cedure}}|
|00005a00| 0a 0a 52 65 74 75 72 6e | 73 20 74 68 65 20 73 75 |..Return|s the su|
|00005a10| 62 6c 69 73 74 20 6f 66 | 20 5c 76 61 72 7b 6c 69 |blist of| \var{li|
|00005a20| 73 74 7d 20 6f 62 74 61 | 69 6e 65 64 20 62 79 20 |st} obta|ined by |
|00005a30| 6f 6d 69 74 74 69 6e 67 | 20 74 68 65 20 66 69 72 |omitting| the fir|
|00005a40| 73 74 20 5c 76 72 7b 6b | 7d 0a 65 6c 65 6d 65 6e |st \vr{k|}.elemen|
|00005a50| 74 73 2e 0a 5c 69 64 65 | 7b 4c 69 73 74 2d 74 61 |ts..\ide|{List-ta|
|00005a60| 69 6c 7d 20 63 6f 75 6c | 64 20 62 65 20 64 65 66 |il} coul|d be def|
|00005a70| 69 6e 65 64 20 62 79 0a | 0a 5c 62 65 67 69 6e 7b |ined by.|.\begin{|
|00005a80| 73 63 68 65 6d 65 7d 0a | 28 64 65 66 69 6e 65 20 |scheme}.|(define |
|00005a90| 6c 69 73 74 2d 74 61 69 | 6c 0a 20 20 28 6c 61 6d |list-tai|l. (lam|
|00005aa0| 62 64 61 20 28 78 20 6b | 29 0a 20 20 20 20 28 69 |bda (x k|). (i|
|00005ab0| 66 20 28 7a 65 72 6f 3f | 20 6b 29 0a 20 20 20 20 |f (zero?| k). |
|00005ac0| 20 20 20 20 78 0a 20 20 | 20 20 20 20 20 20 28 6c | x. | (l|
|00005ad0| 69 73 74 2d 74 61 69 6c | 20 28 63 64 72 20 78 29 |ist-tail| (cdr x)|
|00005ae0| 20 28 2d 20 6b 20 31 29 | 29 29 29 29 25 0a 5c 65 | (- k 1)|))))%.\e|
|00005af0| 6e 64 7b 73 63 68 65 6d | 65 7d 20 0a 5c 65 6e 64 |nd{schem|e} .\end|
|00005b00| 7b 65 6e 74 72 79 7d 0a | 0a 0a 5c 62 65 67 69 6e |{entry}.|..\begin|
|00005b10| 7b 65 6e 74 72 79 7d 7b | 25 0a 5c 70 72 6f 74 6f |{entry}{|%.\proto|
|00005b20| 7b 6c 69 73 74 2d 72 65 | 66 7d 7b 20 6c 69 73 74 |{list-re|f}{ list|
|00005b30| 20 5c 76 72 7b 6b 7d 7d | 7b 65 73 73 65 6e 74 69 | \vr{k}}|{essenti|
|00005b40| 61 6c 20 70 72 6f 63 65 | 64 75 72 65 7d 7d 0a 0a |al proce|dure}}..|
|00005b50| 52 65 74 75 72 6e 73 20 | 74 68 65 20 5c 76 72 7b |Returns |the \vr{|
|00005b60| 6b 7d 74 68 20 65 6c 65 | 6d 65 6e 74 20 6f 66 20 |k}th ele|ment of |
|00005b70| 5c 76 61 72 7b 6c 69 73 | 74 7d 2e 20 20 28 54 68 |\var{lis|t}. (Th|
|00005b80| 69 73 20 69 73 20 74 68 | 65 20 73 61 6d 65 0a 61 |is is th|e same.a|
|00005b90| 73 20 74 68 65 20 63 61 | 72 20 6f 66 20 7b 5c 74 |s the ca|r of {\t|
|00005ba0| 74 28 6c 69 73 74 2d 74 | 61 69 6c 20 5c 76 61 72 |t(list-t|ail \var|
|00005bb0| 7b 6c 69 73 74 7d 20 5c | 76 72 7b 6b 7d 29 7d 2e |{list} \|vr{k})}.|
|00005bc0| 29 0a 0a 5c 62 65 67 69 | 6e 7b 73 63 68 65 6d 65 |)..\begi|n{scheme|
|00005bd0| 7d 0a 28 6c 69 73 74 2d | 72 65 66 20 27 28 61 20 |}.(list-|ref '(a |
|00005be0| 62 20 63 20 64 29 20 32 | 29 20 20 20 20 20 20 20 |b c d) 2|) |
|00005bf0| 20 20 20 20 20 20 20 20 | 20 20 5c 65 76 20 20 63 | | \ev c|
|00005c00| 0a 28 6c 69 73 74 2d 72 | 65 66 20 27 28 61 20 62 |.(list-r|ef '(a b|
|00005c10| 20 63 20 64 29 0a 20 20 | 20 20 20 20 20 20 20 20 | c d). | |
|00005c20| 28 69 6e 65 78 61 63 74 | 2d 3e 65 78 61 63 74 20 |(inexact|->exact |
|00005c30| 28 72 6f 75 6e 64 20 31 | 2e 38 29 29 29 20 5c 6c |(round 1|.8))) \l|
|00005c40| 65 76 20 20 63 25 0a 5c | 65 6e 64 7b 73 63 68 65 |ev c%.\|end{sche|
|00005c50| 6d 65 7d 0a 5c 65 6e 64 | 7b 65 6e 74 72 79 7d 0a |me}.\end|{entry}.|
|00005c60| 0a 0a 25 5c 62 65 67 69 | 6e 7b 65 6e 74 72 79 7d |..%\begi|n{entry}|
|00005c70| 7b 25 0a 25 5c 70 72 6f | 74 6f 7b 6c 61 73 74 2d |{%.%\pro|to{last-|
|00005c80| 70 61 69 72 7d 7b 20 6c | 69 73 74 7d 7b 70 72 6f |pair}{ l|ist}{pro|
|00005c90| 63 65 64 75 72 65 7d 7d | 0a 25 0a 25 52 65 74 75 |cedure}}|.%.%Retu|
|00005ca0| 72 6e 73 20 74 68 65 20 | 6c 61 73 74 20 70 61 69 |rns the |last pai|
|00005cb0| 72 20 69 6e 20 74 68 65 | 20 6e 6f 6e 65 6d 70 74 |r in the| nonempt|
|00005cc0| 79 2c 20 70 6f 73 73 69 | 62 6c 79 20 69 6d 70 72 |y, possi|bly impr|
|00005cd0| 6f 70 65 72 2c 20 6c 69 | 73 74 20 5c 76 61 72 7b |oper, li|st \var{|
|00005ce0| 6c 69 73 74 7d 2e 0a 25 | 5c 69 64 65 7b 4c 61 73 |list}..%|\ide{Las|
|00005cf0| 74 2d 70 61 69 72 7d 20 | 63 6f 75 6c 64 20 62 65 |t-pair} |could be|
|00005d00| 20 64 65 66 69 6e 65 64 | 20 62 79 0a 25 0a 25 5c | defined| by.%.%\|
|00005d10| 62 65 67 69 6e 7b 73 63 | 68 65 6d 65 7d 0a 25 28 |begin{sc|heme}.%(|
|00005d20| 64 65 66 69 6e 65 20 6c | 61 73 74 2d 70 61 69 72 |define l|ast-pair|
|00005d30| 0a 25 20 20 28 6c 61 6d | 62 64 61 20 28 78 29 0a |.% (lam|bda (x).|
|00005d40| 25 20 20 20 20 28 69 66 | 20 28 70 61 69 72 3f 20 |% (if| (pair? |
|00005d50| 28 63 64 72 20 78 29 29 | 0a 25 20 20 20 20 20 20 |(cdr x))|.% |
|00005d60| 20 20 28 6c 61 73 74 2d | 70 61 69 72 20 28 63 64 | (last-|pair (cd|
|00005d70| 72 20 78 29 29 0a 25 20 | 20 20 20 20 20 20 20 78 |r x)).% | x|
|00005d80| 29 29 29 25 0a 25 5c 65 | 6e 64 7b 73 63 68 65 6d |)))%.%\e|nd{schem|
|00005d90| 65 7d 20 0a 25 20 0a 25 | 5c 65 6e 64 7b 65 6e 74 |e} .% .%|\end{ent|
|00005da0| 72 79 7d 0a 0a 0a 5c 62 | 65 67 69 6e 7b 65 6e 74 |ry}...\b|egin{ent|
|00005db0| 72 79 7d 7b 25 0a 5c 70 | 72 6f 74 6f 7b 6d 65 6d |ry}{%.\p|roto{mem|
|00005dc0| 71 7d 7b 20 6f 62 6a 20 | 6c 69 73 74 7d 7b 65 73 |q}{ obj |list}{es|
|00005dd0| 73 65 6e 74 69 61 6c 20 | 70 72 6f 63 65 64 75 72 |sential |procedur|
|00005de0| 65 7d 0a 5c 70 72 6f 74 | 6f 7b 6d 65 6d 76 7d 7b |e}.\prot|o{memv}{|
|00005df0| 20 6f 62 6a 20 6c 69 73 | 74 7d 7b 65 73 73 65 6e | obj lis|t}{essen|
|00005e00| 74 69 61 6c 20 70 72 6f | 63 65 64 75 72 65 7d 0a |tial pro|cedure}.|
|00005e10| 5c 70 72 6f 74 6f 7b 6d | 65 6d 62 65 72 7d 7b 20 |\proto{m|ember}{ |
|00005e20| 6f 62 6a 20 6c 69 73 74 | 7d 7b 65 73 73 65 6e 74 |obj list|}{essent|
|00005e30| 69 61 6c 20 70 72 6f 63 | 65 64 75 72 65 7d 7d 0a |ial proc|edure}}.|
|00005e40| 0a 54 68 65 73 65 20 70 | 72 6f 63 65 64 75 72 65 |.These p|rocedure|
|00005e50| 73 20 72 65 74 75 72 6e | 20 74 68 65 20 66 69 72 |s return| the fir|
|00005e60| 73 74 20 73 75 62 6c 69 | 73 74 20 6f 66 20 5c 76 |st subli|st of \v|
|00005e70| 61 72 7b 6c 69 73 74 7d | 20 77 68 6f 73 65 20 63 |ar{list}| whose c|
|00005e80| 61 72 20 69 73 0a 5c 76 | 61 72 7b 6f 62 6a 7d 2c |ar is.\v|ar{obj},|
|00005e90| 20 77 68 65 72 65 20 74 | 68 65 20 73 75 62 6c 69 | where t|he subli|
|00005ea0| 73 74 73 20 6f 66 20 5c | 76 61 72 7b 6c 69 73 74 |sts of \|var{list|
|00005eb0| 7d 20 61 72 65 20 74 68 | 65 20 6e 6f 6e 2d 65 6d |} are th|e non-em|
|00005ec0| 70 74 79 20 6c 69 73 74 | 73 0a 72 65 74 75 72 6e |pty list|s.return|
|00005ed0| 65 64 20 62 79 20 7b 5c | 74 74 20 28 6c 69 73 74 |ed by {\|tt (list|
|00005ee0| 2d 74 61 69 6c 20 5c 76 | 61 72 7b 6c 69 73 74 7d |-tail \v|ar{list}|
|00005ef0| 20 5c 76 61 72 7b 6b 7d | 29 7d 20 66 6f 72 20 5c | \var{k}|)} for \|
|00005f00| 76 61 72 7b 6b 7d 20 6c | 65 73 73 0a 74 68 61 6e |var{k} l|ess.than|
|00005f10| 20 74 68 65 20 6c 65 6e | 67 74 68 20 6f 66 20 5c | the len|gth of \|
|00005f20| 76 61 72 7b 6c 69 73 74 | 7d 2e 20 20 49 66 0a 5c |var{list|}. If.\|
|00005f30| 76 61 72 7b 6f 62 6a 7d | 20 64 6f 65 73 20 6e 6f |var{obj}| does no|
|00005f40| 74 20 6f 63 63 75 72 20 | 69 6e 20 5c 76 61 72 7b |t occur |in \var{|
|00005f50| 6c 69 73 74 7d 2c 20 74 | 68 65 6e 20 5c 73 63 68 |list}, t|hen \sch|
|00005f60| 66 61 6c 73 65 7b 7d 20 | 28 6e 6f 74 20 74 68 65 |false{} |(not the|
|00005f70| 20 65 6d 70 74 79 20 6c | 69 73 74 29 20 69 73 0a | empty l|ist) is.|
|00005f80| 72 65 74 75 72 6e 65 64 | 2e 20 20 5c 69 64 65 7b |returned|. \ide{|
|00005f90| 4d 65 6d 71 7d 20 75 73 | 65 73 20 5c 69 64 65 7b |Memq} us|es \ide{|
|00005fa0| 65 71 3f 7d 5c 20 74 6f | 20 63 6f 6d 70 61 72 65 |eq?}\ to| compare|
|00005fb0| 20 5c 76 61 72 7b 6f 62 | 6a 7d 20 77 69 74 68 20 | \var{ob|j} with |
|00005fc0| 74 68 65 20 65 6c 65 6d | 65 6e 74 73 20 6f 66 0a |the elem|ents of.|
|00005fd0| 5c 76 61 72 7b 6c 69 73 | 74 7d 2c 20 77 68 69 6c |\var{lis|t}, whil|
|00005fe0| 65 20 5c 69 64 65 7b 6d | 65 6d 76 7d 20 75 73 65 |e \ide{m|emv} use|
|00005ff0| 73 20 5c 69 64 65 7b 65 | 71 76 3f 7d 5c 20 61 6e |s \ide{e|qv?}\ an|
|00006000| 64 20 5c 69 64 65 7b 6d | 65 6d 62 65 72 7d 20 75 |d \ide{m|ember} u|
|00006010| 73 65 73 20 5c 69 64 65 | 7b 65 71 75 61 6c 3f 7d |ses \ide|{equal?}|
|00006020| 2e 0a 0a 5c 62 65 67 69 | 6e 7b 73 63 68 65 6d 65 |...\begi|n{scheme|
|00006030| 7d 0a 28 6d 65 6d 71 20 | 27 61 20 27 28 61 20 62 |}.(memq |'a '(a b|
|00006040| 20 63 29 29 20 20 20 20 | 20 20 20 20 20 20 20 20 | c)) | |
|00006050| 20 20 5c 65 76 20 20 28 | 61 20 62 20 63 29 0a 28 | \ev (|a b c).(|
|00006060| 6d 65 6d 71 20 27 62 20 | 27 28 61 20 62 20 63 29 |memq 'b |'(a b c)|
|00006070| 29 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 5c |) | \|
|00006080| 65 76 20 20 28 62 20 63 | 29 0a 28 6d 65 6d 71 20 |ev (b c|).(memq |
|00006090| 27 61 20 27 28 62 20 63 | 20 64 29 29 20 20 20 20 |'a '(b c| d)) |
|000060a0| 20 20 20 20 20 20 20 20 | 20 20 5c 65 76 20 20 5c | | \ev \|
|000060b0| 73 63 68 66 61 6c 73 65 | 0a 28 6d 65 6d 71 20 28 |schfalse|.(memq (|
|000060c0| 6c 69 73 74 20 27 61 29 | 20 27 28 62 20 28 61 29 |list 'a)| '(b (a)|
|000060d0| 20 63 29 29 20 20 20 20 | 20 5c 65 76 20 20 5c 73 | c)) | \ev \s|
|000060e0| 63 68 66 61 6c 73 65 0a | 28 6d 65 6d 62 65 72 20 |chfalse.|(member |
|000060f0| 28 6c 69 73 74 20 27 61 | 29 0a 20 20 20 20 20 20 |(list 'a|). |
|00006100| 20 20 27 28 62 20 28 61 | 29 20 63 29 29 20 20 20 | '(b (a|) c)) |
|00006110| 20 20 20 20 20 20 20 20 | 20 20 5c 65 76 20 20 28 | | \ev (|
|00006120| 28 61 29 20 63 29 0a 28 | 6d 65 6d 71 20 31 30 31 |(a) c).(|memq 101|
|00006130| 20 27 28 31 30 30 20 31 | 30 31 20 31 30 32 29 29 | '(100 1|01 102))|
|00006140| 20 20 20 20 20 20 20 5c | 65 76 20 20 5c 75 6e 73 | \|ev \uns|
|00006150| 70 65 63 69 66 69 65 64 | 0a 28 6d 65 6d 76 20 31 |pecified|.(memv 1|
|00006160| 30 31 20 27 28 31 30 30 | 20 31 30 31 20 31 30 32 |01 '(100| 101 102|
|00006170| 29 29 20 20 20 20 20 20 | 20 5c 65 76 20 20 28 31 |)) | \ev (1|
|00006180| 30 31 20 31 30 32 29 25 | 0a 5c 65 6e 64 7b 73 63 |01 102)%|.\end{sc|
|00006190| 68 65 6d 65 7d 20 0a 20 | 0a 5c 65 6e 64 7b 65 6e |heme} . |.\end{en|
|000061a0| 74 72 79 7d 0a 0a 0a 5c | 62 65 67 69 6e 7b 65 6e |try}...\|begin{en|
|000061b0| 74 72 79 7d 7b 25 0a 5c | 70 72 6f 74 6f 7b 61 73 |try}{%.\|proto{as|
|000061c0| 73 71 7d 7b 20 6f 62 6a | 20 61 6c 69 73 74 7d 7b |sq}{ obj| alist}{|
|000061d0| 65 73 73 65 6e 74 69 61 | 6c 20 70 72 6f 63 65 64 |essentia|l proced|
|000061e0| 75 72 65 7d 0a 5c 70 72 | 6f 74 6f 7b 61 73 73 76 |ure}.\pr|oto{assv|
|000061f0| 7d 7b 20 6f 62 6a 20 61 | 6c 69 73 74 7d 7b 65 73 |}{ obj a|list}{es|
|00006200| 73 65 6e 74 69 61 6c 20 | 70 72 6f 63 65 64 75 72 |sential |procedur|
|00006210| 65 7d 0a 5c 70 72 6f 74 | 6f 7b 61 73 73 6f 63 7d |e}.\prot|o{assoc}|
|00006220| 7b 20 6f 62 6a 20 61 6c | 69 73 74 7d 7b 65 73 73 |{ obj al|ist}{ess|
|00006230| 65 6e 74 69 61 6c 20 70 | 72 6f 63 65 64 75 72 65 |ential p|rocedure|
|00006240| 7d 7d 0a 0a 5c 64 6f 6d | 61 69 6e 7b 5c 76 61 72 |}}..\dom|ain{\var|
|00006250| 7b 41 6c 69 73 74 7d 20 | 28 66 6f 72 20 60 60 61 |{Alist} |(for ``a|
|00006260| 73 73 6f 63 69 61 74 69 | 6f 6e 20 6c 69 73 74 27 |ssociati|on list'|
|00006270| 27 29 20 6d 75 73 74 20 | 62 65 20 61 20 6c 69 73 |') must |be a lis|
|00006280| 74 20 6f 66 0a 70 61 69 | 72 73 2e 7d 20 20 54 68 |t of.pai|rs.} Th|
|00006290| 65 73 65 20 70 72 6f 63 | 65 64 75 72 65 73 20 66 |ese proc|edures f|
|000062a0| 69 6e 64 20 74 68 65 20 | 66 69 72 73 74 20 70 61 |ind the |first pa|
|000062b0| 69 72 20 69 6e 20 5c 76 | 61 72 7b 61 6c 69 73 74 |ir in \v|ar{alist|
|000062c0| 7d 20 77 68 6f 73 65 20 | 63 61 72 20 66 69 65 6c |} whose |car fiel|
|000062d0| 64 20 69 73 20 5c 76 61 | 72 7b 6f 62 6a 7d 2c 0a |d is \va|r{obj},.|
|000062e0| 61 6e 64 20 72 65 74 75 | 72 6e 73 20 74 68 61 74 |and retu|rns that|
|000062f0| 20 70 61 69 72 2e 20 20 | 49 66 20 6e 6f 20 70 61 | pair. |If no pa|
|00006300| 69 72 20 69 6e 20 5c 76 | 61 72 7b 61 6c 69 73 74 |ir in \v|ar{alist|
|00006310| 7d 20 68 61 73 20 5c 76 | 61 72 7b 6f 62 6a 7d 20 |} has \v|ar{obj} |
|00006320| 61 73 20 69 74 73 0a 63 | 61 72 2c 20 74 68 65 6e |as its.c|ar, then|
|00006330| 20 5c 73 63 68 66 61 6c | 73 65 7b 7d 20 28 6e 6f | \schfal|se{} (no|
|00006340| 74 20 74 68 65 20 65 6d | 70 74 79 20 6c 69 73 74 |t the em|pty list|
|00006350| 29 20 69 73 20 72 65 74 | 75 72 6e 65 64 2e 20 20 |) is ret|urned. |
|00006360| 5c 69 64 65 7b 41 73 73 | 71 7d 20 75 73 65 73 0a |\ide{Ass|q} uses.|
|00006370| 5c 69 64 65 7b 65 71 3f | 7d 5c 20 74 6f 20 63 6f |\ide{eq?|}\ to co|
|00006380| 6d 70 61 72 65 20 5c 76 | 61 72 7b 6f 62 6a 7d 20 |mpare \v|ar{obj} |
|00006390| 77 69 74 68 20 74 68 65 | 20 63 61 72 20 66 69 65 |with the| car fie|
|000063a0| 6c 64 73 20 6f 66 20 74 | 68 65 20 70 61 69 72 73 |lds of t|he pairs|
|000063b0| 20 69 6e 20 5c 76 61 72 | 7b 61 6c 69 73 74 7d 2c | in \var|{alist},|
|000063c0| 0a 77 68 69 6c 65 20 5c | 69 64 65 7b 61 73 73 76 |.while \|ide{assv|
|000063d0| 7d 20 75 73 65 73 20 5c | 69 64 65 7b 65 71 76 3f |} uses \|ide{eqv?|
|000063e0| 7d 5c 20 61 6e 64 20 5c | 69 64 65 7b 61 73 73 6f |}\ and \|ide{asso|
|000063f0| 63 7d 20 75 73 65 73 20 | 5c 69 64 65 7b 65 71 75 |c} uses |\ide{equ|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.